@@ -143,9 +143,14 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs): |
|
|
143 |
143 |
sys._clear_type_cache() |
144 |
144 |
|
145 |
145 |
# Clear ABC registries, restoring previously saved ABC registries. |
146 |
|
-for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]: |
147 |
|
-if not isabstract(abc): |
148 |
|
-continue |
|
146 |
+abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__] |
|
147 |
+abs_classes = filter(isabstract, abs_classes) |
|
148 |
+if 'typing' in sys.modules: |
|
149 |
+t = sys.modules['typing'] |
|
150 |
+# These classes require special treatment because they do not appear |
|
151 |
+# in direct subclasses of collections.abc classes |
|
152 |
+abs_classes = list(abs_classes) + [t.ChainMap, t.Counter, t.DefaultDict] |
|
153 |
+for abc in abs_classes: |
149 |
154 |
for obj in abc.__subclasses__() + [abc]: |
150 |
155 |
obj._abc_registry = abcs.get(obj, WeakSet()).copy() |
151 |
156 |
obj._abc_cache.clear() |