FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-105331: Fix asyncio.sleep() bug by weijay0804 · Pull Request #105641 · python/cpython · GitHub

Repository navigation

gh-105331: Fix asyncio.sleep() bug - #105641

Merged
kumaraditya303 merged 14 commits into
python:mainfrom
weijay0804:fix-issue-105331
Jun 12, 2023
Merged

kumaraditya303 merged 14 commits into
python:mainfrom
weijay0804:fix-issue-105331

Conversation

Copy link
Copy Markdown
Contributor

Issue: gh-105331:
fix asyncio.sleep(float('nan')) does not raise ValueError

Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

Comment thread Lib/asyncio/tasks.py Outdated
"""Create a function suitable for use as a task factory on an event-loop.

Example usage:
Example usage:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please fix the indentation change you (accidentally?) applied to much of this docstring. (Maybe your editor inserted tabs instead of spaces?)

Comment thread Lib/asyncio/tasks.py Outdated
"""Coroutine that completes after a given time (in seconds)."""

# check delay value is not nan
import math

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just move this import to the toplevel, sorted between the rest of the imports.

Comment thread Lib/asyncio/tasks.py Outdated
# check delay value is not nan
import math
if math.isnan(delay):
raise ValueError("Invalid value NaN (not a number)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Suggestion:

Suggested change
raise ValueError("Invalid value NaN (not a number)")
raise ValueError("Invalid delay: NaN (not a number)")

@@ -0,0 +1 @@
fix asyncio.sleep(float('nan')) does not raise ValueErro problem

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please try harder here. The text requires proper punctuation, capitalization, markup, and it should describe the change in behavior rather than just stating "fix the problem".

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

kumaraditya303 left a comment •
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You need to add a test for this and versionchanged for docs that nans are now not allowed.

Comment thread Lib/asyncio/tasks.py Outdated
"""Coroutine that completes after a given time (in seconds)."""

# check delay value is not nan
if math.isnan(delay):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Move this check after delay <= 0 check to not slow down the common case of sleep(0).

…e-105331.nlZvoW.rst


I think this way is more clearer.
Thank you!

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@kumaraditya303 Do you agree?

Copy link
Copy Markdown
Contributor

Do you agree?

I pushed some minor tweaks, now LGTM.

kumaraditya303 enabled auto-merge (squash) June 12, 2023 20:27
kumaraditya303 merged commit f0fb782 into python:main Jun 12, 2023
carljm added a commit to carljm/cpython that referenced this pull request Jun 12, 2023
* main:
  pythongh-105540: Fix code generator tests (python#105707)
  pythongh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields (python#105686)
  pythongh-105331: Change `asyncio.sleep` to raise ``ValueError` for nan (python#105641)
  Remove support for legacy bytecode instructions (python#105705)
weijay0804 deleted the fix-issue-105331 branch June 13, 2023 07:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL