]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix the builtin module initialization code to store the init function for future...
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 18 Jan 2012 19:16:09 +0000 (20:16 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 18 Jan 2012 19:16:09 +0000 (20:16 +0100)
Misc/NEWS
Python/import.c

index b3c5b88bed3563dd47c01a8c687cbf1dcc2688fb..d6728be60bce9353f4465ba3211d0e5d11880a81 100644 (file)
--- 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.
 
index e721498aaa38687730499be755ce9fafc2a6726e..ee3f9b0682f91c1c16320ce785abcce55a40d30d 100644 (file)
@@ -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,