summaryrefslogtreecommitdiffstats
path: root/Lib/abc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/abc.py')
-rw-r--r--Lib/abc.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/abc.py b/Lib/abc.py
index f8e0230..54dc8e2 100644
--- a/Lib/abc.py
+++ b/Lib/abc.py
@@ -3,6 +3,7 @@
"""Abstract Base Classes (ABCs) according to PEP 3119."""
+from weakref import WeakSet
def abstractmethod(funcobj):
"""A decorator indicating abstract methods.
@@ -130,9 +131,9 @@ class ABCMeta(type):
abstracts.add(name)
cls.__abstractmethods__ = abstracts
# Set up inheritance registry
- cls._abc_registry = set()
- cls._abc_cache = set()
- cls._abc_negative_cache = set()
+ cls._abc_registry = WeakSet()
+ cls._abc_cache = WeakSet()
+ cls._abc_negative_cache = WeakSet()
cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
return cls
@@ -172,7 +173,7 @@ class ABCMeta(type):
# Check negative cache; may have to invalidate
if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
# Invalidate the negative cache
- cls._abc_negative_cache = set()
+ cls._abc_negative_cache = WeakSet()
cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
elif subclass in cls._abc_negative_cache:
return False