[Stackless-checkins] r50624 - stackless/trunk/Stackless/pickling/prickelpit.c
richard.tew
python-checkins at python.org
Thu Jul 13 22:08:21 CEST 2006
Author: richard.tew
Date: Thu Jul 13 22:08:21 2006
New Revision: 50624
Modified:
stackless/trunk/Stackless/pickling/prickelpit.c
Log:
Unpickling of a generator creates a temporary generator to do some initialisation which I do not understand the purpose of, however, when this generator is discarded, the frame attached to it is has GeneratorExit raised on it, leaving it ruined for the real use after the unpickling. I clear the frame reference before discarding the temporary generator.
Modified: stackless/trunk/Stackless/pickling/prickelpit.c
==============================================================================
--- stackless/trunk/Stackless/pickling/prickelpit.c (original)
+++ stackless/trunk/Stackless/pickling/prickelpit.c Thu Jul 13 22:08:21 2006
@@ -2025,9 +2025,9 @@
if (!gi_running) {
if ((f = slp_ensure_new_frame(f)) != NULL) {
/* use a second one for late initialization */
- genobject *tmp;
+ genobject *tmpgen;
/* PyGenerator_New eats an existing reference */
- if ((tmp = (genobject *)
+ if ((tmpgen = (genobject *)
PyGenerator_New(f)) == NULL) {
Py_DECREF(f);
return NULL;
@@ -2035,7 +2035,13 @@
Py_INCREF(f);
Py_DECREF(gen->gi_frame);
gen->gi_frame = f;
- Py_DECREF(tmp);
+ /* The frame the temporary generator references
+ will have GeneratorExit raised on it, when the
+ temporary generator is torn down. So clearing
+ the frame from the temporary generator before
+ discarding it, will save the frame for later. */
+ Py_CLEAR(((PyGenObject *)tmpgen)->gi_frame);
+ Py_DECREF(tmpgen);
Py_INCREF(gen);
gen->ob_type = gen->ob_type->tp_base;
}
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list