From 6c40eb7f421804eba3c24a9336c4a9e59dba636c Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 18 Jan 2012 20:16:09 +0100 Subject: Fix the builtin module initialization code to store the init function for future reinitialization. --- Misc/NEWS | 3 +++ Python/import.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index b3c5b88..d6728be 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2.3? 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. diff --git a/Python/import.c b/Python/import.c index e721498..ee3f9b0 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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, -- cgit v0.12