Skip to content

Commit

Permalink
Fix test_regrtest (hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed May 8, 2023
1 parent 424486a commit 8015ba3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Lib/test/libregrtest/refleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ def dash_R(ns, test_name, test_func):
else:
zdc = zipimport._zip_directory_cache.copy()
abcs = {}
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = _get_dump(obj)[0]
# catch and ignore collections.abc.ByteString deprecation
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = _get_dump(obj)[0]

# bpo-31217: Integer pool to get a single integer object for the same
# value. The pool is used to prevent false alarm when checking for memory
Expand Down Expand Up @@ -173,7 +175,9 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
zipimport._zip_directory_cache.update(zdc)

# Clear ABC registries, restoring previously saved ABC registries.
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
# ignore deprecation warning for collections.abc.ByteString
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
abs_classes = filter(isabstract, abs_classes)
for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]:
Expand Down

0 comments on commit 8015ba3

Please sign in to comment.