mirror of https://github.com/python/cpython
Make test_builtin work when executed directly
This commit is contained in:
parent
22ba31a3af
commit
2f9f056db1
|
@ -584,7 +584,10 @@ class BuiltinTest(unittest.TestCase):
|
||||||
raise frozendict_error("frozendict is readonly")
|
raise frozendict_error("frozendict is readonly")
|
||||||
|
|
||||||
# read-only builtins
|
# read-only builtins
|
||||||
frozen_builtins = frozendict(__builtins__)
|
if isinstance(__builtins__, types.ModuleType):
|
||||||
|
frozen_builtins = frozendict(__builtins__.__dict__)
|
||||||
|
else:
|
||||||
|
frozen_builtins = frozendict(__builtins__)
|
||||||
code = compile("__builtins__['superglobal']=2; print(superglobal)", "test", "exec")
|
code = compile("__builtins__['superglobal']=2; print(superglobal)", "test", "exec")
|
||||||
self.assertRaises(frozendict_error,
|
self.assertRaises(frozendict_error,
|
||||||
exec, code, {'__builtins__': frozen_builtins})
|
exec, code, {'__builtins__': frozen_builtins})
|
||||||
|
|
Loading…
Reference in New Issue