From ba7f8638f93b5d999b25d8556ca19bdc2e12f359 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 29 Mar 2021 16:03:16 -0700 Subject: bpo-43660: Fix crash when displaying exceptions with custom values for sys.stderr (GH-25075) (cherry picked from commit 09b90a037d18f5d4acdf1b14082e57bda78e85d3) Co-authored-by: Pablo Galindo --- Python/pythonrun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 3831e81ee9..c55e7674a6 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1034,8 +1034,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