Title: asyncio.sleep(float('nan')) does not raise ValueError · Issue #105331 · python/cpython · GitHub
Open Graph Title: asyncio.sleep(float('nan')) does not raise ValueError · Issue #105331 · python/cpython
X Title: asyncio.sleep(float('nan')) does not raise ValueError · Issue #105331 · python/cpython
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. import asyncio import time try: time.sleep(float('...
Open Graph 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. import asy...
X 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 ValueE...
Opengraph URL: https://github.com/python/cpython/issues/105331
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"asyncio.sleep(float('nan')) does not raise ValueError","articleBody":"# Bug report\r\n`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`.\r\n\r\n```python\r\nimport asyncio\r\nimport time\r\n\r\ntry:\r\n time.sleep(float('nan'))\r\nexcept ValueError:\r\n print(\"time.sleep raised ValueError\")\r\n\r\nasync def foo() -\u003e None:\r\n await asyncio.sleep(float('nan'))\r\n print(\"asyncio.sleep does not raise any error\")\r\n\r\nasyncio.run(foo())\r\n```\r\n\r\n```bash\r\n$ python foo.py\r\ntime.sleep raised ValueError\r\nasyncio.sleep does not raise any error\r\n```\r\n\r\n`time.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: https://github.com/python/cpython/issues/83879\r\n`nan` 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.\r\n\r\nRelated: https://github.com/python-trio/trio/issues/2493\r\n\r\n\r\n# Your environment\r\n\r\n\u003c!-- Include as many relevant details as possible about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on: 3.8 to 3.11 \r\n- Operating system and architecture: `Linux 6.3.4-arch1-1`\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105501\n* gh-105513\n* gh-105641\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/jakkdl","@type":"Person","name":"jakkdl"},"datePublished":"2023-06-05T17:08:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/105331/cpython/issues/105331"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0ce3fd2e-9656-10d3-1e29-51486c50bb43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E45E:30E6E5:1E2AC5E:292D474:696AC3AD |
| html-safe-nonce | 0f44bd24aafce309622ca9a787f9f36d27a538693e6b33cb697d6c6d4bc86f59 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDVFOjMwRTZFNToxRTJBQzVFOjI5MkQ0NzQ6Njk2QUMzQUQiLCJ2aXNpdG9yX2lkIjoiNTUwNzU1NDkzMDQzMzExNTA1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 86cf354b4069a824a97a572ebe53fb2615db9ef297fa38a7fc8c151cef69d7d0 |
| hovercard-subject-tag | issue:1742192813 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/105331/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d1872059aac7c5635425d3ab4f9359e9e703ed7e0496a9043d47779b349f5aaa/python/cpython/issues/105331 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d1872059aac7c5635425d3ab4f9359e9e703ed7e0496a9043d47779b349f5aaa/python/cpython/issues/105331 |
| og:image:alt | 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. import asy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jakkdl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 986b6a1d774985095564e64d6963d11f094da3d0e2bfda2ab1a27d63662eb033 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 89ad2112b9c4e11df6a0c13c8c1f8eedd36b0977 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width