mirror of https://github.com/python/cpython
[3.13] gh-121084: Fix test_typing random leaks (GH-121360) (#121373)
gh-121084: Fix test_typing random leaks (GH-121360)
Clear typing ABC caches when running tests for refleaks (-R option):
call _abc_caches_clear() on typing abstract classes and their
subclasses.
(cherry picked from commit 5f660e8e2c
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
273c993b06
commit
abefbcba8a
|
@ -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