]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` (#143642)
authorJeong, YunWon <69878+youknowone@users.noreply.github.com>
Sat, 10 Jan 2026 09:51:42 +0000 (18:51 +0900)
committerGitHub <noreply@github.com>
Sat, 10 Jan 2026 09:51:42 +0000 (12:51 +0300)
Make ready_to_import always remove tempdir from sys.path

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: