]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 10 Jan 2026 10:17:10 +0000 (11:17 +0100)
committerGitHub <noreply@github.com>
Sat, 10 Jan 2026 10:17:10 +0000 (10:17 +0000)
gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` (GH-143642)

Make ready_to_import always remove tempdir from sys.path
(cherry picked from commit e7f5ffa0de2476828d78b8d39caefc38d797c206)

Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Lib/test/support/import_helper.py

index 0af63501f93bc84d725c6067628528f206ac5223..4c7eac0b7eb674f508fe40e8ad1e0f2b184fa533 100644 (file)
@@ -305,8 +305,8 @@ def ready_to_import(name=None, source=""):
         try:
             sys.path.insert(0, tempdir)
             yield name, path
-            sys.path.remove(tempdir)
         finally:
+            sys.path.remove(tempdir)
             if old_module is not None:
                 sys.modules[name] = old_module
             else: