Skip to content

Commit 79b5d29

Browse files
authored
bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733)
Fix reference hunting (``python3 -m test -R 3:3``) when Python has no built-in abc module: fix _get_dump() reimplementation of libregrtest.
1 parent eb7e29f commit 79b5d29

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Lib/test/libregrtest/refleak.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
try:
99
from _abc import _get_dump
1010
except ImportError:
11+
import weakref
12+
1113
def _get_dump(cls):
12-
# For legacy Python version
13-
return (cls._abc_registry, cls._abc_cache,
14+
# Reimplement _get_dump() for pure-Python implementation of
15+
# the abc module (Lib/_py_abc.py)
16+
registry_weakrefs = set(weakref.ref(obj) for obj in cls._abc_registry)
17+
return (registry_weakrefs, cls._abc_cache,
1418
cls._abc_negative_cache, cls._abc_negative_cache_version)
1519

1620

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix reference hunting (``python3 -m test -R 3:3``) when Python has no
2+
built-in abc module.

0 commit comments

Comments
 (0)