aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/pythonrun.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-07 09:25:06 +0300
committerAlexander Smirnov <alex@ydb.tech>2024-02-09 19:18:32 +0300
commitf0785dc88eee3da0f1514f5b4cafa931571e669d (patch)
tree44165310ad6023cd29776f9b1b4477364cd2b5bb /contrib/tools/python3/src/Python/pythonrun.c
parent2c0985fb513cb5b352324abf223bf749c6c2bd24 (diff)
downloadydb-f0785dc88eee3da0f1514f5b4cafa931571e669d.tar.gz
Update Python 3 to 3.11.8
Diffstat (limited to 'contrib/tools/python3/src/Python/pythonrun.c')
-rw-r--r--contrib/tools/python3/src/Python/pythonrun.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/contrib/tools/python3/src/Python/pythonrun.c b/contrib/tools/python3/src/Python/pythonrun.c
index 91c2ad3a13..fca8b7ab66 100644
--- a/contrib/tools/python3/src/Python/pythonrun.c
+++ b/contrib/tools/python3/src/Python/pythonrun.c
@@ -1200,6 +1200,37 @@ error:
}
static int
+get_exception_notes(struct exception_print_context *ctx, PyObject *value, PyObject **notes) {
+ PyObject *note = NULL;
+
+ if (_PyObject_LookupAttr(value, &_Py_ID(__notes__), notes) < 0) {
+ PyObject *type, *errvalue, *tback;
+ PyErr_Fetch(&type, &errvalue, &tback);
+ PyErr_NormalizeException(&type, &errvalue, &tback);
+ note = PyUnicode_FromFormat("Ignored error getting __notes__: %R", errvalue);
+ Py_XDECREF(type);
+ Py_XDECREF(errvalue);
+ Py_XDECREF(tback);
+ if (!note) {
+ goto error;
+ }
+ *notes = PyList_New(1);
+ if (!*notes) {
+ goto error;
+ }
+ if (PyList_SetItem(*notes, 0, note) < 0) {
+ Py_DECREF(*notes);
+ goto error;
+ }
+ }
+
+ return 0;
+error:
+ Py_XDECREF(note);
+ return -1;
+}
+
+static int
print_exception(struct exception_print_context *ctx, PyObject *value)
{
PyObject *notes = NULL;
@@ -1218,7 +1249,7 @@ print_exception(struct exception_print_context *ctx, PyObject *value)
/* grab the type and notes now because value can change below */
PyObject *type = (PyObject *) Py_TYPE(value);
- if (_PyObject_LookupAttr(value, &_Py_ID(__notes__), &notes) < 0) {
+ if (get_exception_notes(ctx, value, &notes) < 0) {
goto error;
}