Skip to content

Commit f2008da

Browse files
committed
pythongh-105331: Fix asyncio.sleep() bug
1 parent 3a314f7 commit f2008da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Lib/asyncio/tasks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,12 @@ def __sleep0():
642642

643643
async def sleep(delay, result=None):
644644
"""Coroutine that completes after a given time (in seconds)."""
645+
646+
# check delay value is not nan
647+
import math
648+
if math.isnan(delay):
649+
raise ValueError("Invalid value NaN (not a number)")
650+
645651
if delay <= 0:
646652
await __sleep0()
647653
return result

0 commit comments

Comments
 (0)