mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Fix the builtin module initialization code to store the init function for future reinitialization.
This commit is contained in:
parent
0c60381749
commit
6c40eb7f42
2 changed files with 7 additions and 0 deletions
|
@ -2169,6 +2169,7 @@ init_builtin(char *name)
|
|||
|
||||
for (p = PyImport_Inittab; p->name != NULL; p++) {
|
||||
PyObject *mod;
|
||||
PyModuleDef *def;
|
||||
if (strcmp(name, p->name) == 0) {
|
||||
if (p->initfunc == NULL) {
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
|
@ -2181,6 +2182,9 @@ init_builtin(char *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_FixupBuiltin(mod, name) < 0)
|
||||
return -1;
|
||||
/* FixupExtension has put the module into sys.modules,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue