[Python-checkins] cpython (merge 3.2 -> default): Fix the builtin module initialization code to store the init function for
antoine.pitrou
python-checkins at python.org
Wed Jan 18 20:23:42 CET 2012
http://hg.python.org/cpython/rev/3fee4f07aeab
changeset: 74505:3fee4f07aeab
parent: 74503:4724133dc974
parent: 74504:f0cbceef47c3
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Jan 18 20:17:58 2012 +0100
summary:
Fix the builtin module initialization code to store the init function for future reinitialization.
files:
Misc/NEWS | 3 +++
Python/import.c | 4 ++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
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
--- a/Python/import.c
+++ b/Python/import.c
@@ -2542,6 +2542,7 @@
for (p = PyImport_Inittab; p->name != NULL; p++) {
PyObject *mod;
+ PyModuleDef *def;
if (PyUnicode_CompareWithASCIIString(name, p->name) == 0) {
if (p->initfunc == NULL) {
PyErr_Format(PyExc_ImportError,
@@ -2554,6 +2555,9 @@
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_FixupExtensionObject(mod, name, name) < 0)
return -1;
/* FixupExtension has put the module into sys.modules,
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list