summaryrefslogtreecommitdiff
path: root/Python/traceback.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index 06b40bbbdc..3ea1db578b 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -6,11 +6,13 @@
#include "code.h" // PyCode_Addr2Line etc
#include "pycore_interp.h" // PyInterpreterState.gc
#include "frameobject.h" // PyFrame_GetBack()
-#include "pycore_frame.h" // _PyFrame_GetCode()
-#include "pycore_pyarena.h" // _PyArena_Free()
#include "pycore_ast.h" // asdl_seq_*
#include "pycore_compile.h" // _PyAST_Optimize
+#include "pycore_frame.h" // _PyFrame_GetCode()
#include "pycore_parser.h" // _PyParser_ASTFromString
+#include "pycore_pyarena.h" // _PyArena_Free()
+#include "pycore_pyerrors.h" // _PyErr_Fetch()
+#include "pycore_pystate.h" // _PyThreadState_GET()
#include "../Parser/pegen.h" // _PyPegen_byte_offset_to_character_offset()
#include "structmember.h" // PyMemberDef
#include "osdefs.h" // SEP
@@ -267,11 +269,12 @@ void _PyTraceback_Add(const char *funcname, const char *filename, int lineno)
PyCodeObject *code;
PyFrameObject *frame;
PyObject *exc, *val, *tb;
+ PyThreadState *tstate = _PyThreadState_GET();
/* Save and clear the current exception. Python functions must not be
called with an exception set. Calling Python functions happens when
the codec of the filesystem encoding is implemented in pure Python. */
- PyErr_Fetch(&exc, &val, &tb);
+ _PyErr_Fetch(tstate, &exc, &val, &tb);
globals = PyDict_New();
if (!globals)
@@ -281,14 +284,14 @@ void _PyTraceback_Add(const char *funcname, const char *filename, int lineno)
Py_DECREF(globals);
goto error;
}
- frame = PyFrame_New(PyThreadState_Get(), code, globals, NULL);
+ frame = PyFrame_New(tstate, code, globals, NULL);
Py_DECREF(globals);
Py_DECREF(code);
if (!frame)
goto error;
frame->f_lineno = lineno;
- PyErr_Restore(exc, val, tb);
+ _PyErr_Restore(tstate, exc, val, tb);
PyTraceBack_Here(frame);
Py_DECREF(frame);
return;