diff -r 51016ff7f8c9 Objects/genobject.c --- a/Objects/genobject.c Sun Mar 25 22:41:16 2012 -0400 +++ b/Objects/genobject.c Wed Mar 28 12:44:07 2012 +0200 @@ -76,6 +76,7 @@ gen_send_ex(PyGenObject *gen, PyObject * /* Generators always return to their most recent caller, not * necessarily their creator. */ + f->f_tstate = tstate; Py_XINCREF(tstate->frame); assert(f->f_back == NULL); f->f_back = tstate->frame; @@ -89,6 +90,8 @@ gen_send_ex(PyGenObject *gen, PyObject * * cycle. */ assert(f->f_back == tstate->frame); Py_CLEAR(f->f_back); + /* Clear the borrowed reference to the thread state */ + f->f_tstate = NULL; /* If the generator just returned (as opposed to yielding), signal * that the generator is exhausted. */