Skip to content

Commit 997cc69

Browse files
ilevkivskyiserhiy-storchaka
authored andcommitted
Backport fix for spurious refleak failures (#482)
1 parent c6e199f commit 997cc69

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/test/regrtest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,9 +1480,14 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
14801480
sys._clear_type_cache()
14811481

14821482
# Clear ABC registries, restoring previously saved ABC registries.
1483-
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
1484-
if not isabstract(abc):
1485-
continue
1483+
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
1484+
abs_classes = filter(isabstract, abs_classes)
1485+
if 'typing' in sys.modules:
1486+
t = sys.modules['typing']
1487+
# these classes require special treatment because they do not appear
1488+
# in direct subclasses on collections.abc classes
1489+
abs_classes = list(abs_classes) + [t.ChainMap, t.Counter, t.DefaultDict]
1490+
for abc in abs_classes:
14861491
for obj in abc.__subclasses__() + [abc]:
14871492
obj._abc_registry = abcs.get(obj, WeakSet()).copy()
14881493
obj._abc_cache.clear()

0 commit comments

Comments
 (0)