https://github.com/python/cpython/commit/055827528fa50c9a7707792f5fe264c4e20c07e9
commit: 055827528fa50c9a7707792f5fe264c4e20c07e9
branch: main
author: Ɓukasz Langa <luk...@langa.pl>
committer: ambv <luk...@langa.pl>
date: 2025-06-02T16:57:08+02:00
summary:

gh-130999: Fix globals() poisoning in test_traceback (gh-135030)

files:
M Lib/test/test_traceback.py

diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 6b2271f5d5ba8d..74b979d009664d 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -4232,8 +4232,8 @@ def make_module(self, code):
 
         return mod_name
 
-    def get_import_from_suggestion(self, mod_dict, name):
-        modname = self.make_module(mod_dict)
+    def get_import_from_suggestion(self, code, name):
+        modname = self.make_module(code)
 
         def callable():
             try:
@@ -4416,8 +4416,9 @@ def func():
     def test_name_error_suggestions_with_non_string_candidates(self):
         def func():
             abc = 1
-            globals()[0] = 1
-            abv
+            custom_globals = globals().copy()
+            custom_globals[0] = 1
+            print(eval("abv", custom_globals, locals()))
         actual = self.get_suggestion(func)
         self.assertIn("abc", actual)
 

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to