raise an ImportError (rather than fatal) when __import__ is not found in __builtins__ (closes #17867)

This commit is contained in:
Benjamin Peterson 2013-04-29 09:08:14 -04:00
parent 775ccdf1fc
commit 7d110042c5
3 changed files with 11 additions and 1 deletions

View file

@ -324,6 +324,13 @@ class ImportTests(unittest.TestCase):
except ImportError:
self.fail("fromlist must allow bogus names")
@cpython_only
def test_delete_builtins_import(self):
args = ["-c", "del __builtins__.__import__; import os"]
popen = script_helper.spawn_python(*args)
stdout, stderr = popen.communicate()
self.assertIn(b"ImportError", stdout)
@skip_if_dont_write_bytecode
class FilePermissionTests(unittest.TestCase):