This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Changes to generator object's gi_frame attr
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, collinwinter, zseil
Priority: normal Keywords:

Created on 2006-04-04 23:44 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
frame.py akuchling, 2006-04-13 13:40 Demo of gi_frame returning None
Messages (7)
msg28083 - (view) Author: Collin Winter (collinwinter) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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.
History
Date User Action Args
2022-04-11 14:56:16adminsetgithub: 43159
2006-04-04 23:44:13collinwintercreate