[issue14432] Bug in generator if the generator in created in a temporary C thread

STINNER Victor report at bugs.python.org
Fri Dec 13 14:46:08 CET 2013


STINNER Victor added the comment:

> Depends on how you use it, I guess. In many cases (at least for Cython and likely some other low-level tools), it could be as simple as
>
> #if PY_VERSION_HEX < 0x030400B2
>     // set "f_tstate" here
> #endif

Why would you set f_tstate field? Frame constructor (PyFrame_New) and
Generators (gen_send_ex) do it for you.

Cython does touch this field? Stackless Python supports Python 3 (3.4)?

If something relies on f_tstate, it's easy to avoid this field.

> Would it be correct for them to just use the current thread state instead? E.g. from a signal handler that analysis the current threads?

The faulthandler has different low-level C signal handlers and it
doesn't use f_tstate, but PyGILState_GetThisThreadState() (or
PyThreadState_Get() if thread support is disabled).

I was surprised that it was so easy to modify ceval.c: in most cases,
you already have the thread state. So I just passed the thread state
to the function.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14432>
_______________________________________


More information about the Python-bugs-list mailing list