mirror of https://github.com/python/cpython
gh-121084: Fix test_typing random leaks (#121360)
Clear typing ABC caches when running tests for refleaks (-R option): call _abc_caches_clear() on typing abstract classes and their subclasses.
This commit is contained in:
parent
f5c8d67de6
commit
5f660e8e2c
|
@ -264,6 +264,12 @@ def clear_caches():
|
|||
for f in typing._cleanups:
|
||||
f()
|
||||
|
||||
import inspect
|
||||
abs_classes = filter(inspect.isabstract, typing.__dict__.values())
|
||||
for abc in abs_classes:
|
||||
for obj in abc.__subclasses__() + [abc]:
|
||||
obj._abc_caches_clear()
|
||||
|
||||
try:
|
||||
fractions = sys.modules['fractions']
|
||||
except KeyError:
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Fix test_typing random leaks. Clear typing ABC caches when running tests for
|
||||
refleaks (``-R`` option): call ``_abc_caches_clear()`` on typing abstract
|
||||
classes and their subclasses. Patch by Victor Stinner.
|
Loading…
Reference in New Issue