aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/_warnings.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2025-06-13 00:05:26 +0300
committershadchin <shadchin@yandex-team.com>2025-06-13 00:35:30 +0300
commit796b9088366b10b4cd42885101fc20c0b5709b07 (patch)
treef287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Python/_warnings.c
parentc72bca862651e507d2ff4980ef7f4ff7267a7227 (diff)
downloadydb-796b9088366b10b4cd42885101fc20c0b5709b07.tar.gz
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Python/_warnings.c')
-rw-r--r--contrib/tools/python3/Python/_warnings.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/contrib/tools/python3/Python/_warnings.c b/contrib/tools/python3/Python/_warnings.c
index f0ab47efb64..b726c2bf127 100644
--- a/contrib/tools/python3/Python/_warnings.c
+++ b/contrib/tools/python3/Python/_warnings.c
@@ -5,6 +5,8 @@
#include "pycore_pyerrors.h"
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_frame.h"
+#include "pycore_sysmodule.h" // _PySys_GetOptionalAttr()
+
#include "clinic/_warnings.c.h"
#define MODULE_NAME "_warnings"
@@ -493,7 +495,7 @@ static void
show_warning(PyThreadState *tstate, PyObject *filename, int lineno,
PyObject *text, PyObject *category, PyObject *sourceline)
{
- PyObject *f_stderr;
+ PyObject *f_stderr = NULL;
PyObject *name;
char lineno_str[128];
@@ -504,8 +506,7 @@ show_warning(PyThreadState *tstate, PyObject *filename, int lineno,
goto error;
}
- f_stderr = _PySys_GetAttr(tstate, &_Py_ID(stderr));
- if (f_stderr == NULL) {
+ if (_PySys_GetOptionalAttr(&_Py_ID(stderr), &f_stderr) <= 0) {
fprintf(stderr, "lost sys.stderr\n");
goto error;
}
@@ -558,6 +559,7 @@ show_warning(PyThreadState *tstate, PyObject *filename, int lineno,
}
error:
+ Py_XDECREF(f_stderr);
Py_XDECREF(name);
PyErr_Clear();
}