From 89bfc9b0d9033f7c9f086c7281a31a489fe1136f Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 13 Sep 2017 03:27:45 -0700 Subject: [PATCH] [3.6] bpo-31234: test_threaded_import: fix test_side_effect_import() (GH-3189) (#3537) * Don't leak the module into sys.modules * Avoid dangling thread (cherry picked from commit 41bbd82b6b6a887e893974fa5cdaae7782ae6cac) --- Lib/test/test_threaded_import.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index 9b2d9a6f19..f42c900103 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -221,7 +221,8 @@ class ThreadedImportTests(unittest.TestCase): import random t = threading.Thread(target=target) t.start() - t.join()""" + t.join() + t = None""" sys.path.insert(0, os.curdir) self.addCleanup(sys.path.remove, os.curdir) filename = TESTFN + ".py" @@ -232,6 +233,7 @@ class ThreadedImportTests(unittest.TestCase): self.addCleanup(rmtree, '__pycache__') importlib.invalidate_caches() __import__(TESTFN) + del sys.modules[TESTFN] @reap_threads -- 2.40.0