bpo-38070: _Py_DumpTraceback() writes <no Python frame> (GH-16244)
When a Python thread has no frame, _Py_DumpTraceback() and _Py_DumpTracebackThreads() now write "<no Python frame>", rather than writing nothing.
This commit is contained in:
parent
8fc5839a9d
commit
8fa3e1740b
|
@ -797,12 +797,15 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
||||||
PyFrameObject *frame;
|
PyFrameObject *frame;
|
||||||
unsigned int depth;
|
unsigned int depth;
|
||||||
|
|
||||||
if (write_header)
|
if (write_header) {
|
||||||
PUTS(fd, "Stack (most recent call first):\n");
|
PUTS(fd, "Stack (most recent call first):\n");
|
||||||
|
}
|
||||||
|
|
||||||
frame = _PyThreadState_GetFrame(tstate);
|
frame = _PyThreadState_GetFrame(tstate);
|
||||||
if (frame == NULL)
|
if (frame == NULL) {
|
||||||
|
PUTS(fd, "<no Python frame>\n");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
depth = 0;
|
depth = 0;
|
||||||
while (frame != NULL) {
|
while (frame != NULL) {
|
||||||
|
@ -870,9 +873,9 @@ _Py_DumpTracebackThreads(int fd, PyInterpreterState *interp,
|
||||||
Python thread state of the current thread.
|
Python thread state of the current thread.
|
||||||
|
|
||||||
PyThreadState_Get() doesn't give the state of the thread that caused
|
PyThreadState_Get() doesn't give the state of the thread that caused
|
||||||
the fault if the thread released the GIL, and so this function
|
the fault if the thread released the GIL, and so
|
||||||
cannot be used. Read the thread specific storage (TSS) instead: call
|
_PyThreadState_GET() cannot be used. Read the thread specific
|
||||||
PyGILState_GetThisThreadState(). */
|
storage (TSS) instead: call PyGILState_GetThisThreadState(). */
|
||||||
current_tstate = PyGILState_GetThisThreadState();
|
current_tstate = PyGILState_GetThisThreadState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue