comparison Python/pythonrun.c @ 43718:e510b716bd80

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.
author Guido van Rossum <guido@python.org>
date Tue, 30 Oct 2007 18:34:07 +0000
parents 00b136b7da84
children 0d462d789b18
comparison
equal deleted inserted replaced
43717:c1214bd6ed16 43718:e510b716bd80
149 void 149 void
150 Py_InitializeEx(int install_sigs) 150 Py_InitializeEx(int install_sigs)
151 { 151 {
152 PyInterpreterState *interp; 152 PyInterpreterState *interp;
153 PyThreadState *tstate; 153 PyThreadState *tstate;
154 PyObject *bimod, *sysmod; 154 PyObject *bimod, *sysmod, *pstderr;
155 char *p; 155 char *p;
156 #if defined(HAVE_LANGINFO_H) && defined(CODESET) 156 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
157 char *codeset; 157 char *codeset;
158 #endif 158 #endif
159 extern void _Py_ReadyTypes(void); 159 extern void _Py_ReadyTypes(void);
225 Py_INCREF(interp->sysdict); 225 Py_INCREF(interp->sysdict);
226 _PyImport_FixupExtension("sys", "sys"); 226 _PyImport_FixupExtension("sys", "sys");
227 PySys_SetPath(Py_GetPath()); 227 PySys_SetPath(Py_GetPath());
228 PyDict_SetItemString(interp->sysdict, "modules", 228 PyDict_SetItemString(interp->sysdict, "modules",
229 interp->modules); 229 interp->modules);
230
231 /* Set up a preliminary stderr printer until we have enough
232 infrastructure for the io module in place. */
233 pstderr = PyFile_NewStdPrinter(fileno(stderr));
234 if (pstderr == NULL)
235 Py_FatalError("Py_Initialize: can't set preliminary stderr");
236 PySys_SetObject("stderr", pstderr);
230 237
231 _PyImport_Init(); 238 _PyImport_Init();
232 239
233 /* initialize builtin exceptions */ 240 /* initialize builtin exceptions */
234 _PyExc_Init(); 241 _PyExc_Init();