diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-05-20 02:57:59 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-05-20 04:07:17 +0530 |
commit | 1d7656184c6b8aa46b29149893894b3c24f1df00 (patch) | |
tree | b2cd5118498e24c9434e92658c8d44f3ac109679 /yt_dlp/jsinterp.py | |
parent | f7f7a877bf8e87fd4eb0ad2494ad948ca7691114 (diff) | |
download | hypervideo-pre-1d7656184c6b8aa46b29149893894b3c24f1df00.tar.lz hypervideo-pre-1d7656184c6b8aa46b29149893894b3c24f1df00.tar.xz hypervideo-pre-1d7656184c6b8aa46b29149893894b3c24f1df00.zip |
[jsinterp] Handle `NaN` in bitwise operators
Closes #6131
Diffstat (limited to 'yt_dlp/jsinterp.py')
-rw-r--r-- | yt_dlp/jsinterp.py | 7 |
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 |