mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
gh-105331: Change asyncio.sleep to raise `ValueError for nan (#105641)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
9544948e7e
commit
f0fb782ddb
4 changed files with 24 additions and 0 deletions
|
|
@ -15,6 +15,7 @@
|
|||
import functools
|
||||
import inspect
|
||||
import itertools
|
||||
import math
|
||||
import types
|
||||
import warnings
|
||||
import weakref
|
||||
|
|
@ -646,6 +647,9 @@ async def sleep(delay, result=None):
|
|||
await __sleep0()
|
||||
return result
|
||||
|
||||
if math.isnan(delay):
|
||||
raise ValueError("Invalid delay: NaN (not a number)")
|
||||
|
||||
loop = events.get_running_loop()
|
||||
future = loop.create_future()
|
||||
h = loop.call_later(delay,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue