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
+ add also test with nonzero small int
  • Loading branch information
skirpichev committed Mar 14, 2026
commit 20e79c6c3cc5c8a152d2962e98220e30e68ce2dd
5 changes: 3 additions & 2 deletions Lib/test/test_capi/test_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,9 @@ def to_digits(num):

def test_bug_143050(self):
with support.adjust_int_max_str_digits(0):
a = int('-' + '0' * 7000, 10)
del a
int('-' + '0' * 7000, 10)
Comment thread
skirpichev marked this conversation as resolved.
_testcapi.test_immortal_small_ints()
int('-' + '0' * 7000 + '123', 10)
Comment thread
skirpichev marked this conversation as resolved.
_testcapi.test_immortal_small_ints()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm slightly worry that this pass will non-debug builds.

@corona10 (author of #103962), are you sure there is no other way to implement this helper? Return a different value, raise an error?

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.

That's okay as long as it catches the regression in a debug build.

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.

_testcapi is always built with assertions, even in release mode.

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.

I built Python in release mode without PyLong_FromString() fix. _PyLong_FlipSign() assertion didn't catch the bug since Python was built without assertions. But at least, test_immortal_small_ints() was able to detect that small integers were corrupted:

test_bug_143050 (test.test_capi.test_long.LongTests.test_bug_143050) ...
python: ./Modules/_testcapi/immortal.c:35: test_immortal_small_ints: Assertion `has_int_immortal_bit' failed.
Fatal Python error: Aborted

Current thread 0x00007f617b91b780 [python] (most recent call first):
  File "/home/vstinner/python/main/Lib/test/test_capi/test_long.py", line 811 in test_bug_143050



Expand Down
Loading