]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] 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:14:46 +0000 (11:14 +0100)
committerGitHub <noreply@github.com>
Sat, 10 Jan 2026 10:14:46 +0000 (10:14 +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 2b91bdcf9cd8595cabdf1840cd6ff077019f2969..a4ea5bc6af9de01c576fb6e3b9c992ad2f2ae735 100644 (file)
@@ -303,8 +303,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: