aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/jsinterp.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r--yt_dlp/jsinterp.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py
index 5571ecfeb..965b1c0f2 100644
--- a/yt_dlp/jsinterp.py
+++ b/yt_dlp/jsinterp.py
@@ -20,7 +20,12 @@ from .utils import (
def _js_bit_op(op):
def zeroise(x):
- return 0 if x in (None, JS_Undefined) else x
+ if x in (None, JS_Undefined):
+ return 0
+ with contextlib.suppress(TypeError):
+ if math.isnan(x): # NB: NaN cannot be checked by membership
+ return 0
+ return x
def wrapped(a, b):
return op(zeroise(a), zeroise(b)) & 0xffffffff