Make PyTraceBack_Here use the current thread, not the
frame's thread state. Fixes #1579370.
Will backport.
diff --git a/Misc/NEWS b/Misc/NEWS
index 5c3f48d..65b0672 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- Bug #1579370: Make PyTraceBack_Here use the current thread, not the
+ frame's thread state.
+
- patch #1630975: Fix crash when replacing sys.stdout in sitecustomize.py
- Patch #1507247: tarfile.py: use current umask for intermediate
diff --git a/Python/traceback.c b/Python/traceback.c
index cfbd833..4ddee2c 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -113,7 +113,7 @@
int
PyTraceBack_Here(PyFrameObject *frame)
{
- PyThreadState *tstate = frame->f_tstate;
+ PyThreadState *tstate = PyThreadState_GET();
PyTracebackObject *oldtb = (PyTracebackObject *) tstate->curexc_traceback;
PyTracebackObject *tb = newtracebackobject(oldtb, frame);
if (tb == NULL)