-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
GH-141312: Allow only integers to longrangeiter_setstate state #141317
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
GH-141312: Allow only integers to longrangeiter_setstate state #141317
Conversation
|
@serhiy-storchaka Could you please take a look? |
serhiy-storchaka
left a comment
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.
Why not simply check state? Normally, it can only be int.
Using PyLong_Check() is not enough -- it would pass for an int subclass with overridden __radd__, __mul__, etc. PyLong_CheckExact() is needed.
|
Should we change |
Yes we should. It's a bug fix. The rule is that most bugfixes have NEWS. |
|
It is ready for review. |
|
@serhiy-storchaka Could you please take a look? |
Misc/NEWS.d/next/Core_and_Builtins/2025-11-10-23-07-06.gh-issue-141312.H-58GB.rst
Outdated
Show resolved
Hide resolved
…e-141312.H-58GB.rst Co-authored-by: Mikhail Efimov <[email protected]>
efimov-mikhail
left a comment
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.
LGTM
…iryanov/cpython into 141312-longrange-setstate-float
|
I removed checking of exact message and check only an error type. I hope I get you right :) |
serhiy-storchaka
left a comment
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.
Just remove tests with __index__. This is an implementation detail.
|
Done! |
serhiy-storchaka
left a comment
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.
Yet few nitpicks.
Misc/NEWS.d/next/Core_and_Builtins/2025-11-10-23-07-06.gh-issue-141312.H-58GB.rst
Outdated
Show resolved
Hide resolved
|
Done, please take a look. |
vstinner
left a comment
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.
LGTM
serhiy-storchaka
left a comment
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.
LGTM. 👍
|
I suggest to backport this PR for 3.13 and 3.14 since there's an assert crash in debug builds on these Python versions. |
|
Thanks @sergey-miryanov for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ythonGH-141317) This fixes an assertion error when the new computed start is not an integer. (cherry picked from commit 10bec7c) Co-authored-by: Sergey Miryanov <[email protected]>
|
Sorry, @sergey-miryanov and @serhiy-storchaka, I could not cleanly backport this to |
|
GH-141559 is a backport of this pull request to the 3.14 branch. |
|
Looking to manually backport it to 3.13. |
|
GH-141568 is a backport of this pull request to the 3.13 branch. |
… state (pythonGH-141317) This fixes an assertion error when the new computed start is not an integer. (cherry picked from commit 10bec7c) Co-authored-by: Sergey Miryanov <[email protected]>
Only integers should be allowed for the start value in
longrangeiter.Two extra checks were added:
__setstate__forrangeiterfailslongrangeiter.I made the error message for
longrangeitersimilar to that forrangeiter.compute_range_length: Assertion PyLong_Check(start)' failed#141312