diff -r ec00f8570c55 Python/import.c --- a/Python/import.c Mon Nov 05 22:23:16 2012 +0200 +++ b/Python/import.c Tue Nov 06 15:41:51 2012 +0100 @@ -449,13 +449,13 @@ /* 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_FixupExtensionObject() - immediately after the module initialization function succeeds. A - copy can be retrieved from there by calling - _PyImport_FindExtensionObject(). + once, we keep a static dictionary 'extensions' keyed 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_FixupExtensionObject() immediately after the module initialization + function succeeds. A copy can be retrieved from there by calling + _PyImport_FindExtensionObject(). Modules which do support multiple initialization set their m_size field to a non-negative number (indicating the size of the @@ -505,7 +505,7 @@ if (def->m_base.m_copy == NULL) return -1; } - PyDict_SetItem(extensions, filename, (PyObject*)def); + PyDict_SetItem(extensions, PyTuple_Pack(2,filename, name), (PyObject*)def); return 0; } @@ -529,7 +529,7 @@ PyModuleDef* def; if (extensions == NULL) return NULL; - def = (PyModuleDef*)PyDict_GetItem(extensions, filename); + def = (PyModuleDef*)PyDict_GetItem(extensions, PyTuple_Pack(2, filename, name)); if (def == NULL) return NULL; if (def->m_size == -1) {