43 PyThreadState *tstate = PyGILState_GetThisThreadState();
46 PyFrameObject *frame = PyThreadState_GetFrame(tstate);
48 printf(frame ?
"Python stack trace:\n" :
"No Python stack trace available.\n");
51 PyCodeObject *frame_co = PyFrame_GetCode(frame);
52 int line = PyFrame_GetLineNumber(frame);
53 const char *
filename = PyUnicode_AsUTF8(frame_co->co_filename);
54 const char *funcname = PyUnicode_AsUTF8(frame_co->co_name);
57 PyFrameObject *frame_back = PyFrame_GetBack(frame);
64 printf(
"No Python thread state available.\n");