[Python-checkins] r45316 - in python/trunk: Include/genobject.h Objects/genobject.c (original) (raw)

phillip.eby python-checkins at python.org
Wed Apr 12 21:07:15 CEST 2006


Author: phillip.eby Date: Wed Apr 12 21:07:15 2006 New Revision: 45316

Modified: python/trunk/Include/genobject.h python/trunk/Objects/genobject.c Log: Don't set gi_frame to Py_None, use NULL instead, eliminating some insane pointer dereferences.

Modified: python/trunk/Include/genobject.h

--- python/trunk/Include/genobject.h (original) +++ python/trunk/Include/genobject.h Wed Apr 12 21:07:15 2006 @@ -13,6 +13,7 @@ PyObject_HEAD /* The gi_ prefix is intended to remind of generator-iterator. */

Modified: python/trunk/Objects/genobject.c

--- python/trunk/Objects/genobject.c (original) +++ python/trunk/Objects/genobject.c Wed Apr 12 21:07:15 2006 @@ -10,7 +10,8 @@ static int gen_traverse(PyGenObject *gen, visitproc visit, void *arg) { - return visit((PyObject *)gen->gi_frame, arg); + Py_VISIT(gen->gi_frame); + return 0; }

static void @@ -26,7 +27,7 @@

 _PyObject_GC_TRACK(self);

@@ -51,7 +52,7 @@ "generator already executing"); return NULL; } - if ((PyObject )f == Py_None || f->f_stacktop == NULL) { + if (f==NULL || f->f_stacktop == NULL) { / Only set exception if called from send() / if (arg && !exc) PyErr_SetNone(PyExc_StopIteration); return NULL; @@ -98,8 +99,7 @@ if (!result || f->f_stacktop == NULL) { / generator can't be rerun, so release the frame */ Py_DECREF(f); - gen->gi_frame = (PyFrameObject *)Py_None; - Py_INCREF(Py_None); + gen->gi_frame = NULL; }

 return result;

@@ -147,7 +147,7 @@ PyObject *error_type, *error_value, *error_traceback; PyGenObject *gen = (PyGenObject *)self;

@@ -366,7 +366,7 @@ int i; PyFrameObject *f = gen->gi_frame;



More information about the Python-checkins mailing list