msg28083 - (view) |
Author: Collin Winter (collinwinter) *  |
Date: 2006-04-04 23:44 |
In 2.4 (as late as 2.4.3), a generator's gi_frame attribute was always a frame object. In the current SVN revision (43631), gi_frame is sometimes None, a change I can't find any documentation of in the What's New for 2.5 section. If this was intentional, it should be documented -- I can't be the only one with packages that used this behaviour. If it was unintentional, I'd appreciate it if this could be fixed before 2.5 goes out. I don't have a (simple) repro case at this time, but I'll post one as soon as I can simplify the current one down. |
|
|
msg28084 - (view) |
Author: Collin Winter (collinwinter) *  |
Date: 2006-04-04 23:53 |
Logged In: YES user_id=1344176 *stops, thinks, comes up with repro case in 30 seconds* This does indeed seem to be intentional (introduced in r39239 during the implementation of PEP 342). To trigger this, all you have to do is run a generator til exhaustion (ie, StopIteration); at this point, the frame is decref'd and gi_frame is set to None. I'd appreciate it if this could be added to the "Porting to 2.5" section of What's New. Sorry for the confusion. |
|
|
msg28085 - (view) |
Author: Ziga Seilnacht (zseil) *  |
Date: 2006-04-12 23:35 |
Logged In: YES user_id=1326842 This was changed again in revision 45316. The current comment in genobject.h says: Note: gi_frame can be NULL if the generator is "finished" |
|
|
msg28086 - (view) |
Author: A.M. Kuchling (akuchling) *  |
Date: 2006-04-13 12:50 |
Logged In: YES user_id=11375 I've added a mention of this page to the "What's New"; thanks for the suggestion! |
|
|
msg28087 - (view) |
Author: Ziga Seilnacht (zseil) *  |
Date: 2006-04-13 13:30 |
Logged In: YES user_id=1326842 I don't think that your change is correct anymore; Philip J. Eby has changed the behaviour again in revision 45316. The log for his checkin says: Don't set gi_frame to Py_None, use NULL instead, eliminating some insane pointer dereferences. See: http://mail.python.org/pipermail/python-dev/2006-April/063647.html http://mail.python.org/pipermail/python-checkins/2006-April/051180.html for more details. |
|
|
msg28088 - (view) |
Author: A.M. Kuchling (akuchling) *  |
Date: 2006-04-13 13:40 |
Logged In: YES user_id=11375 No, it's correct; I verified it with a small test program. Whether PJE's code uses Py_None or NULL, you still get a None in your Python code. |
|
|
msg28089 - (view) |
Author: Ziga Seilnacht (zseil) *  |
Date: 2006-04-13 13:44 |
Logged In: YES user_id=1326842 Oops, my previous comment is only relevant for C code. Sorry for the noise. |
|
|