diff -burp Python-2.6/Include/import.h Python-2.6-issue4438/Include/import.h --- Python-2.6/Include/import.h 2008-01-04 00:16:32.000000000 +0200 +++ Python-2.6-issue4438/Include/import.h 2008-11-26 15:39:31.000000000 +0200 @@ -16,7 +16,8 @@ PyAPI_FUNC(PyObject *) PyImport_AddModul PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, - PyObject *globals, PyObject *locals, PyObject *fromlist, int level); + PyObject *globals, PyObject *locals, PyObject *fromlist, + int level, char submodule); #define PyImport_ImportModuleEx(n, g, l, f) \ PyImport_ImportModuleLevel(n, g, l, f, -1) diff -burp Python-2.6/Python/bltinmodule.c Python-2.6-issue4438/Python/bltinmodule.c --- Python-2.6/Python/bltinmodule.c 2008-08-18 05:01:21.000000000 +0300 +++ Python-2.6-issue4438/Python/bltinmodule.c 2008-11-26 15:34:20.000000000 +0200 @@ -35,18 +35,20 @@ static PyObject * builtin___import__(PyObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"name", "globals", "locals", "fromlist", - "level", 0}; + "level", "submodule", 0}; char *name; PyObject *globals = NULL; PyObject *locals = NULL; PyObject *fromlist = NULL; int level = -1; + char submodule = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|OOOi:__import__", - kwlist, &name, &globals, &locals, &fromlist, &level)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|OOOib:__import__", + kwlist, &name, &globals, &locals, &fromlist, &level, + &submodule)) return NULL; return PyImport_ImportModuleLevel(name, globals, locals, - fromlist, level); + fromlist, level, submodule); } PyDoc_STRVAR(import_doc, diff -burp Python-2.6/Python/codecs.c Python-2.6-issue4438/Python/codecs.c --- Python-2.6/Python/codecs.c 2008-06-09 07:58:54.000000000 +0300 +++ Python-2.6-issue4438/Python/codecs.c 2008-11-26 15:43:44.000000000 +0200 @@ -842,7 +842,7 @@ static int _PyCodecRegistry_Init(void) interp->codec_error_registry == NULL) Py_FatalError("can't initialize codec registry"); - mod = PyImport_ImportModuleLevel("encodings", NULL, NULL, NULL, 0); + mod = PyImport_ImportModuleLevel("encodings", NULL, NULL, NULL, 0, 0); if (mod == NULL) { if (PyErr_ExceptionMatches(PyExc_ImportError)) { /* Ignore ImportErrors... this is done so that diff -burp Python-2.6/Python/import.c Python-2.6-issue4438/Python/import.c --- Python-2.6/Python/import.c 2008-09-01 17:18:30.000000000 +0300 +++ Python-2.6-issue4438/Python/import.c 2008-11-26 15:46:26.000000000 +0200 @@ -2064,7 +2064,7 @@ static PyObject * import_submodule(PyObj static PyObject * import_module_level(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist, int level) + PyObject *fromlist, int level, char submodule) { char buf[MAXPATHLEN+1]; Py_ssize_t buflen = 0; @@ -2115,13 +2115,13 @@ import_module_level(char *name, PyObject fromlist = NULL; } - if (fromlist == NULL) { + if (fromlist == NULL && !submodule) { Py_DECREF(tail); return head; } Py_DECREF(head); - if (!ensure_fromlist(tail, fromlist, buf, buflen, 0)) { + if (!submodule && !ensure_fromlist(tail, fromlist, buf, buflen, 0)) { Py_DECREF(tail); return NULL; } @@ -2131,11 +2131,12 @@ import_module_level(char *name, PyObject PyObject * PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, - PyObject *fromlist, int level) + PyObject *fromlist, int level, char submodule) { PyObject *result; lock_import(); - result = import_module_level(name, globals, locals, fromlist, level); + result = import_module_level(name, globals, locals, fromlist, level, + submodule); if (unlock_import() < 0) { Py_XDECREF(result); PyErr_SetString(PyExc_RuntimeError, @@ -2701,7 +2702,7 @@ PyImport_Import(PyObject *module_name) PyErr_Clear(); builtins = PyImport_ImportModuleLevel("__builtin__", - NULL, NULL, NULL, 0); + NULL, NULL, NULL, 0, 0); if (builtins == NULL) return NULL; globals = Py_BuildValue("{OO}", builtins_str, builtins);