Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-105331: move import math to the toplevel
  • Loading branch information
weijay0804 committed Jun 11, 2023
commit 588bbbd8fa0006c060bece8468366d4e44782bf1
2 changes: 1 addition & 1 deletion Lib/asyncio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import functools
import inspect
import itertools
import math
import types
import warnings
import weakref
Expand Down Expand Up @@ -644,7 +645,6 @@ async def sleep(delay, result=None):
"""Coroutine that completes after a given time (in seconds)."""

# check delay value is not nan
import math
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.

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

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.

Suggestion:

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


Expand Down