-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-105331: Fix asyncio.sleep() bug #105501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
weijay0804
commented
Jun 8, 2023
•
edited by bedevere-bot
Loading
edited by bedevere-bot
- Issue: asyncio.sleep(float('nan')) does not raise ValueError #105331
- Issue: asyncio.sleep(float('nan')) does not raise ValueError #105331
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
@@ -639,10 +639,34 @@ def __sleep0(): | |||
""" | |||
yield | |||
|
|||
def __check_delay(delay): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Does it really need double underscore? If you want to mark something as "private API" use one leading underscore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get it!
Thank you
|
||
SEC_TO_NS = 1000 * 1000 * 1000 | ||
|
||
if not (isinstance(delay, int) or isinstance(delay, float)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not (isinstance(delay, int) or isinstance(delay, float)): | |
if not isinstance(delay, (int, float)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! This is much clearer now.
SEC_TO_NS = 1000 * 1000 * 1000 | ||
|
||
if not (isinstance(delay, int) or isinstance(delay, float)): | ||
raise TypeError(f"'{type(delay)} object cannot be interpreted as an integer'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise TypeError(f"'{type(delay)} object cannot be interpreted as an integer'") | |
raise TypeError(f"{type(delay)} object cannot be interpreted as an integer") |
There's no need for single quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Thank you