Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upPickling of exhausted generator objects fails #130
Comments
PyEval_ReInitThread can run arbitrary Python code, which really ought to have the TLS initialized.
Pickling of an exhausted generator no longer causes a segmentation fault. https://bitbucket.org/stackless-dev/stackless/issues/130 (grafted from b86bda31f4e3372bbde61179cc890af24d83ae71)
Originally reported by: Anselm Kruis (Bitbucket: akruis, GitHub: akruis)
If you pickle an exhausted generator you get a SystemError (2.7-slp) or an access violation (3.x). The cause for this bug is obvious: generator->gi_frame is NULL and pricklepit.c gen_reduce() does not handle this situation.
The fix is simple: change gen_reduce() to return Py_None, if generator->gi_frame is NULL. change gen_setstate() to set gen->gi_frame to NULL, if the frame is Py_None.