Skip to content

[2.7] bpo-30675: Fix refleak hunting in regrtest #2227

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

Merged
merged 1 commit into from
Jun 16, 2017
Merged
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
17 changes: 17 additions & 0 deletions Lib/test/regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,

if slaveargs is not None:
args, kwargs = json.loads(slaveargs)
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to backport the slaveargs changes just backported to 3.5? Or there is no need?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not interested to backport this change. While regrtest of 3.5 is old, regrtest of 2.7 is even older. Backporting regrtest enhancements is more and more complex :-/

If we want to get more new regrtest features, I would prefer to "simply" copy regrtest from master to other branches.

if kwargs['huntrleaks']:
warm_caches()
if testdir:
kwargs['testdir'] = testdir
try:
Expand All @@ -448,6 +450,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
print json.dumps(result)
sys.exit(0)

if huntrleaks:
warm_caches()

good = []
bad = []
skipped = []
Expand Down Expand Up @@ -1418,6 +1423,18 @@ def clear_caches():
# Collect cyclic trash.
gc.collect()

def warm_caches():
"""Create explicitly internal singletons which are created on demand
to prevent false positive when hunting reference leaks."""
# char cache
for i in range(256):
chr(i)
# unicode cache
for i in range(256):
unichr(i)
# int cache
list(range(-5, 257))

def findtestdir(path=None):
return path or os.path.dirname(__file__) or os.curdir

Expand Down