diff -r 1c54def5947c Python/import.c --- a/Python/import.c Mon Nov 05 00:55:06 2012 +0100 +++ b/Python/import.c Tue Nov 06 16:07:43 2012 +0100 @@ -563,13 +563,12 @@ /* Magic for extension modules (built-in as well as dynamically loaded). To prevent initializing an extension module more than - once, we keep a static dictionary 'extensions' keyed by module name - (for built-in modules) or by filename (for dynamically loaded - modules), containing these modules. A copy of the module's - dictionary is stored by calling _PyImport_FixupExtension() - immediately after the module initialization function succeeds. A - copy can be retrieved from there by calling - _PyImport_FindExtension(). */ + once, we keep a static dictionary 'extensions' keyed by by the tuple (module + name, module name) (for built-in modules) or by (filename, module name) + (for dynamically loaded modules) , containing these modules. A copy of the + module's dictionary is stored by calling _PyImport_FixupExtension() + immediately after the module initialization function succeeds. A copy can + be retrieved from there by calling _PyImport_FindExtension(). */ PyObject * _PyImport_FixupExtension(char *name, char *filename) @@ -593,7 +592,7 @@ copy = PyDict_Copy(dict); if (copy == NULL) return NULL; - PyDict_SetItemString(extensions, filename, copy); + PyDict_SetItem(extensions, Py_BuildValue("(ss)", filename, name), copy); Py_DECREF(copy); return copy; } @@ -604,7 +603,7 @@ PyObject *dict, *mod, *mdict; if (extensions == NULL) return NULL; - dict = PyDict_GetItemString(extensions, filename); + dict = PyDict_GetItem(extensions, Py_BuildValue("(ss)", filename, name)); if (dict == NULL) return NULL; mod = PyImport_AddModule(name);