Commit bf02fb28 authored by Guido van Rossum's avatar Guido van Rossum

Make sure that the message "Error in sys.exitfunc:" goes to sys.stderr

and not to C's stderr.
parent 6deac7a1
...@@ -1052,12 +1052,14 @@ call_sys_exitfunc() ...@@ -1052,12 +1052,14 @@ call_sys_exitfunc()
PyObject *exitfunc = PySys_GetObject("exitfunc"); PyObject *exitfunc = PySys_GetObject("exitfunc");
if (exitfunc) { if (exitfunc) {
PyObject *res; PyObject *res, *f;
Py_INCREF(exitfunc); Py_INCREF(exitfunc);
PySys_SetObject("exitfunc", (PyObject *)NULL); PySys_SetObject("exitfunc", (PyObject *)NULL);
f = PySys_GetObject("stderr");
res = PyEval_CallObject(exitfunc, (PyObject *)NULL); res = PyEval_CallObject(exitfunc, (PyObject *)NULL);
if (res == NULL) { if (res == NULL) {
fprintf(stderr, "Error in sys.exitfunc:\n"); if (f)
PyFile_WriteString("Error in sys.exitfunc:\n", f);
PyErr_Print(); PyErr_Print();
} }
Py_DECREF(exitfunc); Py_DECREF(exitfunc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment