From 09b90a037d18f5d4acdf1b14082e57bda78e85d3 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Mon, 29 Mar 2021 23:38:51 +0100 Subject: bpo-43660: Fix crash when displaying exceptions with custom values for sys.stderr (GH-25075) --- Python/pythonrun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index b562875f8a..1715cde49d 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1082,8 +1082,9 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) if (file == Py_None) { return; } - + Py_INCREF(file); _PyErr_Display(file, exception, value, tb); + Py_DECREF(file); } PyObject * -- cgit v1.2.1