Skip to content

bpo-31217: Fix regrtest -R for small integer #3258

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
13 changes: 10 additions & 3 deletions Lib/test/libregrtest/refleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
from test import support


def maybe_small_long(x):
# bpo-31217: On CPython, x_sub() of longobject.c doesn't try to use int
# singletons. Try to get singletons to prevent false alarms on memory block
# leaks.
return int(str(x))
Copy link
Member

Choose a reason for hiding this comment

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

Rather than rely on small int singletons, I think an explicit pool would be less implementation-dependent.



def dash_R(the_module, test, indirect_test, huntrleaks):
"""Run a test multiple times, looking for reference leaks.

Expand Down Expand Up @@ -56,9 +63,9 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
abcs)
print('.', end='', file=sys.stderr, flush=True)
if i >= nwarmup:
rc_deltas[i] = rc_after - rc_before
alloc_deltas[i] = alloc_after - alloc_before
fd_deltas[i] = fd_after - fd_before
rc_deltas[i] = maybe_small_long(rc_after - rc_before)
alloc_deltas[i] = maybe_small_long(alloc_after - alloc_before)
fd_deltas[i] = maybe_small_long(fd_after - fd_before)
alloc_before = alloc_after
rc_before = rc_after
fd_before = fd_after
Expand Down