summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-30 18:34:07 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-30 18:34:07 (GMT)
commit826d8973ac52a0a8155ef857c8a9bf18a90b11ac (patch)
tree228f7830ba30118bed52db846a39b2ef1f9c0fda /Python/pythonrun.c
parent1cd5bd2a2e600d0f29f9dcfbb9ea922cb1cd006f (diff)
downloadcpython-826d8973ac52a0a8155ef857c8a9bf18a90b11ac.zip
cpython-826d8973ac52a0a8155ef857c8a9bf18a90b11ac.tar.gz
cpython-826d8973ac52a0a8155ef857c8a9bf18a90b11ac.tar.bz2
Patch 1352 (continued in issue 1329) by Christian Heimes.
Before sys.stderr is set to the proper thing, set it to a really simple file-like object that can print tracebacks using direct file descriptor I/O. This is handy for debugging.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 76da8fb..ec9ed02 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -151,7 +151,7 @@ Py_InitializeEx(int install_sigs)
{
PyInterpreterState *interp;
PyThreadState *tstate;
- PyObject *bimod, *sysmod;
+ PyObject *bimod, *sysmod, *pstderr;
char *p;
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
char *codeset;
@@ -228,6 +228,13 @@ Py_InitializeEx(int install_sigs)
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);
+
_PyImport_Init();
/* initialize builtin exceptions */