summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-10-30 21:48:26 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-10-30 21:48:26 (GMT)
commit6a27efa2d321c2b262c0cab3c2d4af3e2e8a9ead (patch)
tree8b5388600b6df266a89b8ec1324ae6441cfbd032 /Python
parent5833a2f6fdc6ee58b23a02380093bf1bfb015f3c (diff)
downloadcpython-6a27efa2d321c2b262c0cab3c2d4af3e2e8a9ead.zip
cpython-6a27efa2d321c2b262c0cab3c2d4af3e2e8a9ead.tar.gz
cpython-6a27efa2d321c2b262c0cab3c2d4af3e2e8a9ead.tar.bz2
Issue 3723: Fixed initialization of subinterpreters
The patch fixes several issues with Py_NewInterpreter as well as the demo for multiple subinterpreters. Most of the patch was written by MvL with help from Benjamin, Amaury and me. Graham Dumpleton has verified that this patch fixes an issue with mod_wsgi.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c2
-rw-r--r--Python/codecs.c1
-rw-r--r--Python/pystate.c1
-rw-r--r--Python/pythonrun.c16
-rw-r--r--Python/sysmodule.c2
5 files changed, 20 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8159fe8..d7f5084 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2282,7 +2282,7 @@ static struct PyModuleDef builtinsmodule = {
PyModuleDef_HEAD_INIT,
"builtins",
builtin_doc,
- 0,
+ -1, /* multiple "initialization" just copies the module dict. */
builtin_methods,
NULL,
NULL,
diff --git a/Python/codecs.c b/Python/codecs.c
index 66576c4..ebddc09 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -869,5 +869,6 @@ static int _PyCodecRegistry_Init(void)
return -1;
}
Py_DECREF(mod);
+ interp->codecs_initialized = 1;
return 0;
}
diff --git a/Python/pystate.c b/Python/pystate.c
index 9479256..2a9b744 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -76,6 +76,7 @@ PyInterpreterState_New(void)
interp->codec_search_path = NULL;
interp->codec_search_cache = NULL;
interp->codec_error_registry = NULL;
+ interp->codecs_initialized = 0;
#ifdef HAVE_DLOPEN
#ifdef RTLD_NOW
interp->dlopenflags = RTLD_NOW;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4fb2b3e..61cdf6d 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -562,8 +562,13 @@ Py_NewInterpreter(void)
goto handle_error;
Py_INCREF(interp->builtins);
}
+
+ /* initialize builtin exceptions */
+ _PyExc_Init();
+
sysmod = _PyImport_FindExtension("sys", "sys");
if (bimod != NULL && sysmod != NULL) {
+ PyObject *pstderr;
interp->sysdict = PyModule_GetDict(sysmod);
if (interp->sysdict == NULL)
goto handle_error;
@@ -571,7 +576,18 @@ Py_NewInterpreter(void)
PySys_SetPath(Py_GetPath());
PyDict_SetItemString(interp->sysdict, "modules",
interp->modules);
+ /* Set up a preliminary stderr printer until we have enough
+ infrastructure for the io module in place. */
+ pstderr = PyFile_NewStdPrinter(fileno(stderr));
+ if (pstderr == NULL)
+ Py_FatalError("Py_Initialize: can't set preliminary stderr");
+ PySys_SetObject("stderr", pstderr);
+ PySys_SetObject("__stderr__", pstderr);
+
_PyImportHooks_Init();
+ if (initstdio() < 0)
+ Py_FatalError(
+ "Py_Initialize: can't initialize sys standard streams");
initmain();
if (!Py_NoSiteFlag)
initsite();
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 952f7e5..af960bc 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1231,7 +1231,7 @@ static struct PyModuleDef sysmodule = {
PyModuleDef_HEAD_INIT,
"sys",
sys_doc,
- 0,
+ -1, /* multiple "initialization" just copies the module dict. */
sys_methods,
NULL,
NULL,