]> 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:17:58 +0000 (20:17 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 18 Jan 2012 19:17:58 +0000 (20:17 +0100)
1  2 
Misc/NEWS
Python/import.c

diff --cc Misc/NEWS
Simple merge
diff --cc Python/import.c
index 4efc36923a30c968f052573f2344406f53aa6ebf,ee3f9b0682f91c1c16320ce785abcce55a40d30d..76f40d300b5e0ec7eceaf8d31c7e14c5fab44a0d
@@@ -2542,10 -2169,11 +2542,11 @@@ init_builtin(PyObject *name
  
      for (p = PyImport_Inittab; p->name != NULL; p++) {
          PyObject *mod;
 -        if (strcmp(name, p->name) == 0) {
+         PyModuleDef *def;
 +        if (PyUnicode_CompareWithASCIIString(name, p->name) == 0) {
              if (p->initfunc == NULL) {
                  PyErr_Format(PyExc_ImportError,
 -                    "Cannot re-init internal module %.200s",
 +                    "Cannot re-init internal module %R",
                      name);
                  return -1;
              }
              mod = (*p->initfunc)();
              if (mod == 0)
                  return -1;
 -            if (_PyImport_FixupBuiltin(mod, name) < 0)
+             /* 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,
                 so we can release our own reference. */