aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/traceback.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-04-18 12:39:32 +0300
committershadchin <shadchin@yandex-team.ru>2022-04-18 12:39:32 +0300
commitd4be68e361f4258cf0848fc70018dfe37a2acc24 (patch)
tree153e294cd97ac8b5d7a989612704a0c1f58e8ad4 /contrib/tools/python3/src/Python/traceback.c
parent260c02f5ccf242d9d9b8a873afaf6588c00237d6 (diff)
downloadydb-d4be68e361f4258cf0848fc70018dfe37a2acc24.tar.gz
IGNIETFERRO-1816 Update Python 3 from 3.9.12 to 3.10.4
ref:9f96be6d02ee8044fdd6f124b799b270c20ce641
Diffstat (limited to 'contrib/tools/python3/src/Python/traceback.c')
-rw-r--r--contrib/tools/python3/src/Python/traceback.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/contrib/tools/python3/src/Python/traceback.c b/contrib/tools/python3/src/Python/traceback.c
index 23d0e38e73..7d6f7f435a 100644
--- a/contrib/tools/python3/src/Python/traceback.c
+++ b/contrib/tools/python3/src/Python/traceback.c
@@ -4,6 +4,7 @@
#include "Python.h"
#include "code.h"
+#include "pycore_interp.h" // PyInterpreterState.gc
#include "frameobject.h" // PyFrame_GetBack()
#include "structmember.h" // PyMemberDef
#include "osdefs.h" // SEP
@@ -147,7 +148,7 @@ static PyMethodDef tb_methods[] = {
};
static PyMemberDef tb_memberlist[] = {
- {"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|READ_RESTRICTED},
+ {"tb_frame", T_OBJECT, OFF(tb_frame), READONLY|PY_AUDIT_READ},
{"tb_lasti", T_INT, OFF(tb_lasti), READONLY},
{"tb_lineno", T_INT, OFF(tb_lineno), READONLY},
{NULL} /* Sentinel */
@@ -233,7 +234,7 @@ _PyTraceBack_FromFrame(PyObject *tb_next, PyFrameObject *frame)
assert(tb_next == NULL || PyTraceBack_Check(tb_next));
assert(frame != NULL);
- return tb_create_raw((PyTracebackObject *)tb_next, frame, frame->f_lasti,
+ return tb_create_raw((PyTracebackObject *)tb_next, frame, frame->f_lasti*sizeof(_Py_CODEUNIT),
PyFrame_GetLineNumber(frame));
}
@@ -419,12 +420,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
Py_DECREF(io);
Py_DECREF(binary);
- PyMem_FREE(found_encoding);
+ PyMem_Free(found_encoding);
return 0;
}
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
Py_DECREF(io);
- PyMem_FREE(found_encoding);
+ PyMem_Free(found_encoding);
if (fob == NULL) {
PyErr_Clear();
@@ -628,12 +629,12 @@ PyTraceBack_Print(PyObject *v, PyObject *f)
This function is signal safe. */
void
-_Py_DumpDecimal(int fd, unsigned long value)
+_Py_DumpDecimal(int fd, size_t value)
{
/* maximum number of characters required for output of %lld or %p.
We need at most ceil(log10(256)*SIZEOF_LONG_LONG) digits,
plus 1 for the null byte. 53/22 is an upper bound for log10(256). */
- char buffer[1 + (sizeof(unsigned long)*53-1) / 22 + 1];
+ char buffer[1 + (sizeof(size_t)*53-1) / 22 + 1];
char *ptr, *end;
end = &buffer[Py_ARRAY_LENGTH(buffer) - 1];
@@ -649,15 +650,12 @@ _Py_DumpDecimal(int fd, unsigned long value)
_Py_write_noraise(fd, ptr, end - ptr);
}
-/* Format an integer in range [0; 0xffffffff] to hexadecimal of 'width' digits,
- and write it into the file fd.
-
- This function is signal safe. */
-
+/* Format an integer as hexadecimal with width digits into fd file descriptor.
+ The function is signal safe. */
void
-_Py_DumpHexadecimal(int fd, unsigned long value, Py_ssize_t width)
+_Py_DumpHexadecimal(int fd, uintptr_t value, Py_ssize_t width)
{
- char buffer[sizeof(unsigned long) * 2 + 1], *ptr, *end;
+ char buffer[sizeof(uintptr_t) * 2 + 1], *ptr, *end;
const Py_ssize_t size = Py_ARRAY_LENGTH(buffer) - 1;
if (width > size)
@@ -788,11 +786,10 @@ dump_frame(int fd, PyFrameObject *frame)
PUTS(fd, "???");
}
- /* PyFrame_GetLineNumber() was introduced in Python 2.7.0 and 3.2.0 */
- int lineno = PyCode_Addr2Line(code, frame->f_lasti);
+ int lineno = PyFrame_GetLineNumber(frame);
PUTS(fd, ", line ");
if (lineno >= 0) {
- _Py_DumpDecimal(fd, (unsigned long)lineno);
+ _Py_DumpDecimal(fd, (size_t)lineno);
}
else {
PUTS(fd, "???");
@@ -826,7 +823,7 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
// not modify Python objects.
frame = tstate->frame;
if (frame == NULL) {
- PUTS(fd, "<no Python frame>\n");
+ PUTS(fd, " <no Python frame>\n");
return;
}
@@ -940,6 +937,9 @@ _Py_DumpTracebackThreads(int fd, PyInterpreterState *interp,
break;
}
write_thread_id(fd, tstate, tstate == current_tstate);
+ if (tstate == current_tstate && tstate->interp->gc.collecting) {
+ PUTS(fd, " Garbage-collecting\n");
+ }
dump_traceback(fd, tstate, 0);
tstate = PyThreadState_Next(tstate);
nthreads++;