[Stackless-checkins] r53566 - stackless/branches/release25-maint/Stackless/core/stacklesseval.c

richard.tew python-checkins at python.org
Thu Jan 25 22:24:18 CET 2007


Author: richard.tew
Date: Thu Jan 25 22:24:17 2007
New Revision: 53566

Modified:
   stackless/branches/release25-maint/Stackless/core/stacklesseval.c
Log:
Refixed the bug Jeff Senn's generator leakage test reproduced.
http://www.stackless.com/pipermail/stackless/2006-December/002144.html

Modified: stackless/branches/release25-maint/Stackless/core/stacklesseval.c
==============================================================================
--- stackless/branches/release25-maint/Stackless/core/stacklesseval.c	(original)
+++ stackless/branches/release25-maint/Stackless/core/stacklesseval.c	Thu Jan 25 22:24:17 2007
@@ -542,6 +542,7 @@
 	if (result == Py_None && f->f_stacktop == NULL) {
 		Py_DECREF(result);
 		result = NULL;
+		/* Set exception if not called by gen_iternext() */
 		if (arg)
 			PyErr_SetNone(PyExc_StopIteration);
 		/* Stackless extra handling */
@@ -553,14 +554,18 @@
 		}
 	}
 
+	/* We hold references to things in the cframe, if we release it
+	   before we clear the references, they get incorrectly and
+	   prematurely free. */
+	cf->ob1 = NULL;
+	cf->ob2 = NULL;
+
 	if (!result || f->f_stacktop == NULL) {
 		/* generator can't be rerun, so release the frame */
 		Py_DECREF(f);
 		gen->gi_frame = NULL;
 	}
 
-	cf->ob1 = NULL;
-	cf->ob2 = NULL;
 	Py_DECREF(gen);
 	Py_XDECREF(arg);
 	return result;

_______________________________________________
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