From: Antoine Pitrou Date: Wed, 18 Jan 2012 19:17:58 +0000 (+0100) Subject: Fix the builtin module initialization code to store the init function for future... X-Git-Tag: v3.3.0a1~352 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=165e01f83f64061fc66440e2e13b095d4ce9c755;p=thirdparty%2FPython%2Fcpython.git Fix the builtin module initialization code to store the init function for future reinitialization. --- 165e01f83f64061fc66440e2e13b095d4ce9c755 diff --cc Python/import.c index 4efc36923a30,ee3f9b0682f9..76f40d300b5e --- a/Python/import.c +++ b/Python/import.c @@@ -2542,10 -2169,11 +2542,11 @@@ init_builtin(PyObject *name for (p = PyImport_Inittab; p->name != NULL; p++) { PyObject *mod; + PyModuleDef *def; - if (strcmp(name, p->name) == 0) { + 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; } @@@ -2554,7 -2182,10 +2555,10 @@@ 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) + if (_PyImport_FixupExtensionObject(mod, name, name) < 0) return -1; /* FixupExtension has put the module into sys.modules, so we can release our own reference. */