Skip to content

[3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901)#147437

Merged
vstinner merged 3 commits intopython:3.13from
vstinner:long_fromstring13
Mar 31, 2026
Merged

[3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901)#147437
vstinner merged 3 commits intopython:3.13from
vstinner:long_fromstring13

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Mar 31, 2026

The long_from_string_base() might return a small integer, when the _pylong.py is used to do conversion. Hence, we must be careful here to not smash it "small int" bit by using the _PyLong_FlipSign().

(cherry picked from commit db5936c)

…ython#145901)

The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit db5936c)
@vstinner
Copy link
Copy Markdown
Member Author

@skirpichev: I backported manually the change to 3.13. I reimplemented _PyLong_IsSmallInt() for 3.13.

@vstinner vstinner merged commit 01af34a into python:3.13 Mar 31, 2026
40 checks passed
@vstinner vstinner deleted the long_fromstring13 branch March 31, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants