diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-04-29 09:08:33 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-04-29 09:08:33 -0400 |
commit | 5c089314efb94d3ab4ddfea9c27d408e97ec3ff2 (patch) | |
tree | 7320d963eb87096ccf4897b033e0fc51cac81472 | |
parent | 91c2f37e216acbb3f3e8c6662999889d9f34ef0e (diff) | |
parent | 7d110042c5a2b27ffd0b3ae25dc7722f2f8bc5c5 (diff) | |
download | cpython-git-5c089314efb94d3ab4ddfea9c27d408e97ec3ff2.tar.gz |
merge 3.3
-rw-r--r-- | Lib/test/test_import.py | 7 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Python/import.c | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 470a6d2392..8be66a1893 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -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): @@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #17867: Raise an ImportError if __import__ is not found in __builtins__. + - Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3, such as was shipped with Centos 5 and Mac OS X 10.4. diff --git a/Python/import.c b/Python/import.c index 8773be46ad..805cdd7e2a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1403,7 +1403,8 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, if (builtins_import == NULL) { builtins_import = _PyDict_GetItemId(interp->builtins, &PyId___import__); if (builtins_import == NULL) { - Py_FatalError("__import__ missing"); + PyErr_SetString(PyExc_ImportError, "__import__ not found"); + goto error_with_unlock; } } Py_INCREF(builtins_import); |