[Python-Dev] Meaning of the f_tstate field in the frame object

Mark Shannon mark at hotpy.org
Wed Apr 11 11:56:04 CEST 2012


What is the purpose of the f_tstate field in the frame object?
It holds a borrowed reference to the threadstate in which the frame
was created.

If PyThreadState_GET()->frame->f_state == PyThreadState_GET()
then it is redundant.

But what if PyThreadState_GET()->frame->f_state != PyThreadState_GET(),
which can happen when a generator is created in one thread and called in
another?

Removing the f_tstate field provides a clean fix to 
http://bugs.python.org/issue14432, but is it safe to do so?
I think it is safe, but does anyone think otherwise?

(Removing it requires the replacement of frame->f_state
with PyThreadState_GET() at one place in _PyEval_CallTracing)

Cheers,
Mark.


More information about the Python-Dev mailing list