[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
- Previous message: [Python-checkins] r43637 - in external/sqlite-source-3.3.4: amd64 amd64/build.bat ia64 ia64/build.bat
- Next message: [Python-checkins] r43639 - in python/trunk: PCbuild/_sqlite3.vcproj Tools/msi/msi.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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)
def test_abs(self): # intself.assertRaises(ValueError, __import__, '')
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) {
/* empty module name only happens in 'from . import' */
/* completely empty module name should only happen in
'from . import' (or '__import__("")')*/ Py_INCREF(mod); *p_name = NULL; return mod;
- Previous message: [Python-checkins] r43637 - in external/sqlite-source-3.3.4: amd64 amd64/build.bat ia64 ia64/build.bat
- Next message: [Python-checkins] r43639 - in python/trunk: PCbuild/_sqlite3.vcproj Tools/msi/msi.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]