https://github.com/python/cpython/commit/7c99a42d102c452b8e38bb4969fe81de18855d29
commit: 7c99a42d102c452b8e38bb4969fe81de18855d29
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-01-10T10:14:46Z
summary:

[3.13] gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` 
(GH-143642) (#143648)

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 <[email protected]>

files:
M Lib/test/support/import_helper.py

diff --git a/Lib/test/support/import_helper.py 
b/Lib/test/support/import_helper.py
index 2b91bdcf9cd859..a4ea5bc6af9de0 100644
--- a/Lib/test/support/import_helper.py
+++ b/Lib/test/support/import_helper.py
@@ -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:

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to