GH-141312: Allow only integers to longrangeiter_setstate state#141317
GH-141312: Allow only integers to longrangeiter_setstate state#141317serhiy-storchaka merged 18 commits intopython:mainfrom
Conversation
|
@serhiy-storchaka Could you please take a look? |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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 <efimov.mikhail@gmail.com>
|
Done! |
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. |
|
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 <sergey.miryanov@gmail.com>
|
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 <sergey.miryanov@gmail.com>
…GH-141317) (GH-141568) This fixes an assertion error when the new computed start is not an integer. (cherry picked from commit 10bec7c)
|
Thanks everyone for review! |
…GH-141317) (GH-141559) This fixes an assertion error when the new computed start is not an integer. (cherry picked from commit 10bec7c) Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
…ythonGH-141317) This fixes an assertion error when the new computed start is not an integer.
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