Skip to content

Commit bf02fb2

Browse files
committed
Make sure that the message "Error in sys.exitfunc:" goes to sys.stderr
and not to C's stderr.
1 parent 6deac7a commit bf02fb2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Python/pythonrun.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1052,12 +1052,14 @@ call_sys_exitfunc()
10521052
PyObject *exitfunc = PySys_GetObject("exitfunc");
10531053

10541054
if (exitfunc) {
1055-
PyObject *res;
1055+
PyObject *res, *f;
10561056
Py_INCREF(exitfunc);
10571057
PySys_SetObject("exitfunc", (PyObject *)NULL);
1058+
f = PySys_GetObject("stderr");
10581059
res = PyEval_CallObject(exitfunc, (PyObject *)NULL);
10591060
if (res == NULL) {
1060-
fprintf(stderr, "Error in sys.exitfunc:\n");
1061+
if (f)
1062+
PyFile_WriteString("Error in sys.exitfunc:\n", f);
10611063
PyErr_Print();
10621064
}
10631065
Py_DECREF(exitfunc);

0 commit comments

Comments
 (0)