summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-21 21:57:42 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-21 21:57:42 (GMT)
commit1d6af707cfac6406feb5c82656bb8f313bfcb696 (patch)
tree8d991ca2e933414b6e449f5e658208338cd4d1fe /Python/pythonrun.c
parentffbc2f63e1ae5356e03f8b0cbf606616c311862e (diff)
downloadcpython-1d6af707cfac6406feb5c82656bb8f313bfcb696.zip
cpython-1d6af707cfac6406feb5c82656bb8f313bfcb696.tar.gz
cpython-1d6af707cfac6406feb5c82656bb8f313bfcb696.tar.bz2
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/pythonrun.c')
-rw-r--r--Python/pythonrun.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f4f8766..55b9d50 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);