summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
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/pythonrun.c
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/pythonrun.c')
-rw-r--r--Python/pythonrun.c16
1 files changed, 16 insertions, 0 deletions
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();