Skip to content

Commit 8c469cf

Browse files
committed
Fix test_regrtest (hopefull)
1 parent 424486a commit 8c469cf

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Lib/test/libregrtest/refleak.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ def dash_R(ns, test_name, test_func):
4848
else:
4949
zdc = zipimport._zip_directory_cache.copy()
5050
abcs = {}
51-
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
52-
if not isabstract(abc):
53-
continue
54-
for obj in abc.__subclasses__() + [abc]:
55-
abcs[obj] = _get_dump(obj)[0]
51+
# catch and ignore collections.abc.ByteString deprecation
52+
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
53+
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
54+
if not isabstract(abc):
55+
continue
56+
for obj in abc.__subclasses__() + [abc]:
57+
abcs[obj] = _get_dump(obj)[0]
5658

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

175177
# Clear ABC registries, restoring previously saved ABC registries.
176-
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
178+
# ignore deprecation warning for collections.abc.ByteString
179+
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
180+
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
177181
abs_classes = filter(isabstract, abs_classes)
178182
for abc in abs_classes:
179183
for obj in abc.__subclasses__() + [abc]:

0 commit comments

Comments
 (0)