Skip to content
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