diff options
author | shadchin <shadchin@yandex-team.com> | 2025-06-13 00:05:26 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2025-06-13 00:35:30 +0300 |
commit | 796b9088366b10b4cd42885101fc20c0b5709b07 (patch) | |
tree | f287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Python/errors.c | |
parent | c72bca862651e507d2ff4980ef7f4ff7267a7227 (diff) | |
download | ydb-796b9088366b10b4cd42885101fc20c0b5709b07.tar.gz |
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Python/errors.c')
-rw-r--r-- | contrib/tools/python3/Python/errors.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/tools/python3/Python/errors.c b/contrib/tools/python3/Python/errors.c index e4b7fd6b242..d45615f96b0 100644 --- a/contrib/tools/python3/Python/errors.c +++ b/contrib/tools/python3/Python/errors.c @@ -1567,14 +1567,15 @@ write_unraisable_exc(PyThreadState *tstate, PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb, PyObject *err_msg, PyObject *obj) { - PyObject *file = _PySys_GetAttr(tstate, &_Py_ID(stderr)); + PyObject *file; + if (_PySys_GetOptionalAttr(&_Py_ID(stderr), &file) < 0) { + return -1; + } if (file == NULL || file == Py_None) { + Py_XDECREF(file); return 0; } - /* Hold a strong reference to ensure that sys.stderr doesn't go away - while we use it */ - Py_INCREF(file); int res = write_unraisable_exc_file(tstate, exc_type, exc_value, exc_tb, err_msg, obj, file); Py_DECREF(file); @@ -1671,13 +1672,20 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, PyObject *obj) goto error; } - PyObject *hook = _PySys_GetAttr(tstate, &_Py_ID(unraisablehook)); + PyObject *hook; + if (_PySys_GetOptionalAttr(&_Py_ID(unraisablehook), &hook) < 0) { + Py_DECREF(hook_args); + err_msg_str = NULL; + obj = NULL; + goto error; + } if (hook == NULL) { Py_DECREF(hook_args); goto default_hook; } 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; @@ -1685,11 +1693,13 @@ _PyErr_WriteUnraisableMsg(const char *err_msg_str, 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); |