Skip to content

Commit 41bbd82

Browse files
authored
bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189)
* Don't leak the module into sys.modules * Avoid dangling thread
1 parent 830d7d2 commit 41bbd82

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎Lib/test/test_threaded_import.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def target():
230230
import random
231231
t = threading.Thread(target=target)
232232
t.start()
233-
t.join()"""
233+
t.join()
234+
t = None"""
234235
sys.path.insert(0, os.curdir)
235236
self.addCleanup(sys.path.remove, os.curdir)
236237
filename = TESTFN + ".py"
@@ -241,6 +242,7 @@ def target():
241242
self.addCleanup(rmtree, '__pycache__')
242243
importlib.invalidate_caches()
243244
__import__(TESTFN)
245+
del sys.modules[TESTFN]
244246

245247

246248
@reap_threads

0 commit comments

Comments
 (0)