[Python-checkins] r43638 - in python/trunk: Lib/test/test_builtin.py Python/import.c (original) (raw)

thomas.wouters python-checkins at python.org
Tue Apr 4 18:17:02 CEST 2006


Author: thomas.wouters Date: Tue Apr 4 18:17:02 2006 New Revision: 43638

Modified: python/trunk/Lib/test/test_builtin.py python/trunk/Python/import.c Log:

Fix import("") to raise ValueError rather than return None.

Modified: python/trunk/Lib/test/test_builtin.py

--- python/trunk/Lib/test/test_builtin.py (original) +++ python/trunk/Lib/test/test_builtin.py Tue Apr 4 18:17:02 2006 @@ -108,6 +108,7 @@ import('string') self.assertRaises(ImportError, import, 'spamspam') self.assertRaises(TypeError, import, 1, 2, 3, 4)

Modified: python/trunk/Python/import.c

--- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Tue Apr 4 18:17:02 2006 @@ -1934,6 +1934,14 @@ } tail = next; } + if (tail == Py_None) { + /* If tail is Py_None, both get_parent and load_next found + an empty module name: someone called import("") or + doctored faulty bytecode */ + PyErr_SetString(PyExc_ValueError, + "Empty module name"); + return NULL; + }

 if (fromlist != NULL) {
     if (fromlist == Py_None || !PyObject_IsTrue(fromlist))

@@ -2094,7 +2102,8 @@ PyObject *result;

 if (strlen(name) == 0) {


More information about the Python-checkins mailing list