]> granicus.if.org Git - python/commitdiff
bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733)
authorVictor Stinner <vstinner@redhat.com>
Mon, 8 Apr 2019 23:36:34 +0000 (01:36 +0200)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2019 23:36:34 +0000 (01:36 +0200)
Fix reference hunting (``python3 -m test -R 3:3``) when Python has no
built-in abc module: fix _get_dump() reimplementation of libregrtest.

Lib/test/libregrtest/refleak.py
Misc/NEWS.d/next/Tests/2019-04-08-19-01-21.bpo-36565.2bxgtU.rst [new file with mode: 0644]

index 6724488fcfb088e46c7755f81c793738e16eb186..d68ea63b5b3c1385072fb28788646640cfaccc29 100644 (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)
 
 
diff --git a/Misc/NEWS.d/next/Tests/2019-04-08-19-01-21.bpo-36565.2bxgtU.rst b/Misc/NEWS.d/next/Tests/2019-04-08-19-01-21.bpo-36565.2bxgtU.rst
new file mode 100644 (file)
index 0000000..8a14d08
--- /dev/null
@@ -0,0 +1,2 @@
+Fix reference hunting (``python3 -m test -R 3:3``) when Python has no
+built-in abc module.