Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
weijay0804 wants to merge2 commits intopython:mainfromweijay0804:fix-issue-105331
Closed

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

weijay0804 wants to merge2 commits intopython:mainfromweijay0804:fix-issue-105331

Conversation

@weijay0804
Copy link
Contributor

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

raiseTypeError(f"{type(delay)} object cannot be interpreted as an integer")

# According to Modules/timemodule.c
if (delay>sys.maxsize/SEC_TO_NS):
Copy link
Member

@Eclips4Eclips4Jun 8, 2023
edited
Loading

Choose a reason for hiding this comment

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

It is incorrect because of 32-bit platform (and that's why asyncio test failing on Windows 32-bit).
sys.maxsize on 32-bit platform equal to2 ** 31 -1.
So, in that casesys.maxsize / SEC_TO_NS is equal to2.147483647

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Oh!
I forgot about this matter.
Intimemodule.c, INT64_MAX is used and is not subject to the limitation of 32-bit.
If I write it asINT64_MAX = 2**64 - 1, how would it be?

if (delay > INT64_MAX / SEC_TO_NS)

Copy link
Member

Choose a reason for hiding this comment

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

Oh! I forgot about this matter. Intimemodule.c, INT64_MAX is used and is not subject to the limitation of 32-bit. If I write it asINT64_MAX = 2**64 - 1, how would it be?

if (delay > INT64_MAX / SEC_TO_NS)

I think it's correct solution, but I'm not expert in this area. Let's wait for other opinions

weijay0804 reacted with heart emoji
if (delay<0):
raiseValueError("sleep length must be non-negative")

if (math.isnan(delay)):
Copy link
Member

Choose a reason for hiding this comment

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

Also, seems there need to add check that delay is finite number. Use something likeif not math.isfinite(delay): ... for resolve that.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This appears to be more accurate.

Thank you!

@gvanrossum
Copy link
Member

This PR has some scope creep compared to the issue it purports to fix -- it changes the behavior if the delay is negative. While this was discussed in the issue, no conclusion was drawn (there were conflicting opinions).

If it wasjust the NaN check I'd approve it after fixing the grammar, punctuation and markup in the NEWS file, but as it is, I can't.

@weijay0804weijay0804 closed this by deleting the head repositoryJun 11, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Eclips4Eclips4Eclips4 left review comments

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303kumaraditya303 is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@weijay0804@bedevere-bot@gvanrossum@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp