Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
time.sleep(float('nan')) raisesValueError, butasyncio.sleep(float('nan')) is valid and sleeps for 0. This seems bad, andasyncio.sleep should probably also raiseValueError.
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.pytime.sleep raised ValueErrorasyncio.sleep does not raise any error
time.sleep andasyncio.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 shouldvery 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
Projects
Status
Done