Fix the builtin module initialization code to store the init function for future reinitialization.

This commit is contained in:
Antoine Pitrou 2012-01-18 20:17:58 +01:00
commit 165e01f83f
2 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
- Fix the builtin module initialization code to store the init function for
future reinitialization.
- Issue #13629: Renumber the tokens in token.h so that they match the indexes
into _PyParser_TokenNames.

View File

@ -2542,6 +2542,7 @@ init_builtin(PyObject *name)
for (p = PyImport_Inittab; p->name != NULL; p++) {
PyObject *mod;
PyModuleDef *def;
if (PyUnicode_CompareWithASCIIString(name, p->name) == 0) {
if (p->initfunc == NULL) {
PyErr_Format(PyExc_ImportError,
@ -2554,6 +2555,9 @@ init_builtin(PyObject *name)
mod = (*p->initfunc)();
if (mod == 0)
return -1;
/* Remember pointer to module init function. */
def = PyModule_GetDef(mod);
def->m_base.m_init = p->initfunc;
if (_PyImport_FixupExtensionObject(mod, name, name) < 0)
return -1;
/* FixupExtension has put the module into sys.modules,