Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
Description
Bug report
time.sleep(float('nan')) raises ValueError, but asyncio.sleep(float('nan')) is valid and sleeps for 0. This seems bad, and asyncio.sleep should probably also raise ValueError.
importasyncioimporttimetry: time.sleep(float('nan')) exceptValueError: print("time.sleep raised ValueError") asyncdeffoo() ->None: awaitasyncio.sleep(float('nan')) print("asyncio.sleep does not raise any error") asyncio.run(foo())$ python foo.py time.sleep raised ValueError asyncio.sleep does not raise any errortime.sleep and asyncio.sleep do differ in behaviour when it comes to negative numbers and changing that behaviour was considered a breaking change without strong reason: #83879nan feels like it should very rare to be passed intentionally, but the potential gain might also be small enough that this isn't worth fixing.
Related: python-trio/trio#2493
Your environment
- CPython versions tested on: 3.8 to 3.11
- Operating system and architecture:
Linux 6.3.4-arch1-1
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done