aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/traceback.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/traceback.c
parentc72bca862651e507d2ff4980ef7f4ff7267a7227 (diff)
downloadydb-796b9088366b10b4cd42885101fc20c0b5709b07.tar.gz
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Python/traceback.c')
-rw-r--r--contrib/tools/python3/Python/traceback.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/contrib/tools/python3/Python/traceback.c b/contrib/tools/python3/Python/traceback.c
index fba3594e97c..1cb82c57203 100644
--- a/contrib/tools/python3/Python/traceback.c
+++ b/contrib/tools/python3/Python/traceback.c
@@ -13,6 +13,7 @@
#include "pycore_pyarena.h" // _PyArena_Free()
#include "pycore_pyerrors.h" // _PyErr_GetRaisedException()
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_sysmodule.h" // _PySys_GetOptionalAttr()
#include "pycore_traceback.h" // EXCEPTION_TB_HEADER
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
@@ -349,9 +350,13 @@ _Py_FindSourceFile(PyObject *filename, char* namebuf, size_t namelen, PyObject *
taillen = strlen(tail);
PyThreadState *tstate = _PyThreadState_GET();
- syspath = _PySys_GetAttr(tstate, &_Py_ID(path));
- if (syspath == NULL || !PyList_Check(syspath))
+ if (_PySys_GetOptionalAttr(&_Py_ID(path), &syspath) < 0) {
+ PyErr_Clear();
+ goto error;
+ }
+ if (syspath == NULL || !PyList_Check(syspath)) {
goto error;
+ }
npath = PyList_Size(syspath);
open = PyObject_GetAttr(io, &_Py_ID(open));
@@ -394,6 +399,7 @@ error:
result = NULL;
finally:
Py_XDECREF(open);
+ Py_XDECREF(syspath);
Py_DECREF(filebytes);
return result;
}
@@ -1064,17 +1070,21 @@ _PyTraceBack_Print_Indented(PyObject *v, int indent, const char *margin,
PyErr_BadInternalCall();
return -1;
}
- limitv = PySys_GetObject("tracebacklimit");
- if (limitv && PyLong_Check(limitv)) {
+ if (_PySys_GetOptionalAttrString("tracebacklimit", &limitv) < 0) {
+ return -1;
+ }
+ else if (limitv != NULL && PyLong_Check(limitv)) {
int overflow;
limit = PyLong_AsLongAndOverflow(limitv, &overflow);
if (overflow > 0) {
limit = LONG_MAX;
}
else if (limit <= 0) {
+ Py_DECREF(limitv);
return 0;
}
}
+ Py_XDECREF(limitv);
if (_Py_WriteIndentedMargin(indent, header_margin, f) < 0) {
return -1;
}