Skip to content

Commit c6d794f

Browse files
committed
Address ref leak in inspect triggered by call to files().
1 parent aa331ff commit c6d794f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_importlib/resources/test_files.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import unittest
44
import warnings
55
import importlib
6+
import inspect
67
import contextlib
78

89
from importlib import resources
@@ -90,6 +91,12 @@ def test_module_resources(self):
9091

9192

9293
class ImplicitContextFilesTests(SiteDir, unittest.TestCase):
94+
95+
def tearDown(self):
96+
# clean up inspect state to avoid ref leaks (#116731)
97+
inspect._filesbymodname.clear()
98+
inspect.modulesbyfile.clear()
99+
93100
def test_implicit_files(self):
94101
"""
95102
Without any parameter, files() will infer the location as the caller.

0 commit comments

Comments
 (0)