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.
This commit is contained in:
Victor Stinner 2019-04-09 01:36:34 +02:00 committed by GitHub
parent eb7e29f2a9
commit 79b5d29041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -8,9 +8,13 @@ from test import support
try:
from _abc import _get_dump
except ImportError:
import weakref
def _get_dump(cls):
# For legacy Python version
return (cls._abc_registry, cls._abc_cache,
# Reimplement _get_dump() for pure-Python implementation of
# the abc module (Lib/_py_abc.py)
registry_weakrefs = set(weakref.ref(obj) for obj in cls._abc_registry)
return (registry_weakrefs, cls._abc_cache,
cls._abc_negative_cache, cls._abc_negative_cache_version)

View File

@ -0,0 +1,2 @@
Fix reference hunting (``python3 -m test -R 3:3``) when Python has no
built-in abc module.