diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-21 21:57:42 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-03-21 21:57:42 +0000 |
commit | 323c36c411fce5ff2f99bb28d821af8125a3895d (patch) | |
tree | f41525021091ee4a1890d61a5b9f7eda55bfb221 /Python | |
parent | 14349c187f87094381852457f81f99e29be8171d (diff) | |
download | cpython-323c36c411fce5ff2f99bb28d821af8125a3895d.tar.gz |
Revert my change on initsite(): don't change import site error handler in 3.1,
as I did for 2.6. But fix the other bugs :-)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pythonrun.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index f4f87662d2..55b9d50e50 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -712,12 +712,22 @@ initmain(void) static void initsite(void) { - PyObject *m; + PyObject *m, *f; m = PyImport_ImportModule("site"); if (m == NULL) { - PyErr_Print(); - Py_Finalize(); - exit(1); + f = PySys_GetObject("stderr"); + if (f == NULL || f == Py_None) + return; + if (Py_VerboseFlag) { + PyFile_WriteString( + "'import site' failed; traceback:\n", f); + PyErr_Print(); + } + else { + PyFile_WriteString( + "'import site' failed; use -v for traceback\n", f); + PyErr_Clear(); + } } else { Py_DECREF(m); |