mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-121084: Fix test_typing random leaks (GH-121360) (#121372)
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
8d3f44ad01
commit
4bf4cc22c4
2 changed files with 9 additions and 0 deletions
|
@ -264,6 +264,12 @@ def clear_caches():
|
||||||
for f in typing._cleanups:
|
for f in typing._cleanups:
|
||||||
f()
|
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:
|
try:
|
||||||
fractions = sys.modules['fractions']
|
fractions = sys.modules['fractions']
|
||||||
except KeyError:
|
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…
Add table
Add a link
Reference in a new issue