mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-130999: Fix globals() poisoning in test_traceback (gh-135030)
This commit is contained in:
parent
26a1cd4e8c
commit
055827528f
1 changed files with 5 additions and 4 deletions
|
@ -4232,8 +4232,8 @@ class SuggestionFormattingTestBase:
|
|||
|
||||
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 @@ class SuggestionFormattingTestBase:
|
|||
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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue