summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/python3/Python/errors.c')
-rw-r--r--contrib/tools/python3/Python/errors.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/contrib/tools/python3/Python/errors.c b/contrib/tools/python3/Python/errors.c
index 63e4844b1c0..b565722ef56 100644
--- a/contrib/tools/python3/Python/errors.c
+++ b/contrib/tools/python3/Python/errors.c
@@ -1598,6 +1598,7 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
_Py_EnsureTstateNotNULL(tstate);
PyObject *err_msg = NULL;
+ PyObject *hook = NULL;
PyObject *exc_type, *exc_value, *exc_tb;
_PyErr_Fetch(tstate, &exc_type, &exc_value, &exc_tb);
@@ -1642,7 +1643,6 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
goto error;
}
- PyObject *hook;
if (_PySys_GetOptionalAttr(&_Py_ID(unraisablehook), &hook) < 0) {
Py_DECREF(hook_args);
err_msg_str = NULL;
@@ -1655,7 +1655,6 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
}
if (_PySys_Audit(tstate, "sys.unraisablehook", "OO", hook, hook_args) < 0) {
- Py_DECREF(hook);
Py_DECREF(hook_args);
err_msg_str = "Exception ignored in audit hook";
obj = NULL;
@@ -1663,13 +1662,11 @@ format_unraisable_v(const char *format, va_list va, PyObject *obj)
}
if (hook == Py_None) {
- Py_DECREF(hook);
Py_DECREF(hook_args);
goto default_hook;
}
PyObject *res = PyObject_CallOneArg(hook, hook_args);
- Py_DECREF(hook);
Py_DECREF(hook_args);
if (res != NULL) {
Py_DECREF(res);
@@ -1699,6 +1696,7 @@ done:
Py_XDECREF(exc_value);
Py_XDECREF(exc_tb);
Py_XDECREF(err_msg);
+ Py_XDECREF(hook);
_PyErr_Clear(tstate); /* Just in case */
}