Issue1473257
Created on 2006-04-19 21:39 by collinwinter, last changed 2008-01-26 14:14 by georg.brandl.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
gi_code.patch
|
collinwinter,
2006-05-18 17:11
|
Add gi_code attr to generators, against r46040 |
|
|
|
NEWS.diff
|
collinwinter,
2006-05-18 17:12
|
Add an item to Misc/NEWS about the gi_code attr, against r46040 |
|
|
|
msg50081 - (view) |
Author: Collin Winter (collinwinter) |
Date: 2006-04-19 21:39 |
|
In the test suite for one of my packages, I've used
something like gen.gi_frame.f_code.co_name to help make
human-readable assertions about when certain generators
are run deep inside the application. This was possible
because Python 2.4 guaranteed that gi_frame was always
a frame instance, even after the generator exhausted
itself. In Python 2.5, however, gi_frame is None when
the generator has run till exhaustion, meaning that I
can't always get to f_code.co_name.
I'd like to add a gi_code attribute to generators that
would allow users to access the code object behind the
generator, even when gi_frame is None. This attribute
would be read-only and would follow this rule:
>>> def f():
... yield 5
...
>>> g = f()
>>> g.gi_code is f.func_code
True
>>>
The attached patch (against r45570) implements the
proposed attribute (in Include/genobject.h and
Objects/genobject.c) and adds test cases to
Lib/test/test_generators.py for this attribute.
|
|
msg50082 - (view) |
Author: Collin Winter (collinwinter) |
Date: 2006-04-29 21:11 |
|
Logged In: YES
user_id=1344176
I've updated the patch; it's now against SVN r45808.
|
|
msg50083 - (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2006-04-30 11:17 |
|
Logged In: YES
user_id=849994
Phillip, do you have an opinion on this one?
|
|
msg50084 - (view) |
Author: Collin Winter (collinwinter) |
Date: 2006-05-18 17:13 |
|
Logged In: YES
user_id=1344176
In addition to updating the main patch to r46040, I've
included a diff against Misc/NEWS to make mention of the
gi_code attribute.
Any thoughts on getting this into 2.5a3?
|
|
msg61270 - (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-01-20 11:18 |
|
Guido, do you have an opinion? Seems like a nonproblematic and probably
useful change for 2.6.
|
|
msg61476 - (view) |
Author: Guido van Rossum (gvanrossum) |
Date: 2008-01-22 01:58 |
|
I noticed some whitespace issues in the patch, but apart from that I
have no objection. (Not any particular enthusiasm, I have to admit -- I
don't quite get the use case, but as Georg remarks, it seems harmless.)
|
|
msg61710 - (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-01-26 14:14 |
|
Reformatted the patch to use tabs and committed as r60324.
|
|
| Date |
User |
Action |
Args |
| 2008-01-26 14:14:40 | georg.brandl | set | status: open -> closed assignee: gvanrossum -> georg.brandl resolution: accepted messages:
+ msg61710 |
| 2008-01-22 01:58:17 | gvanrossum | set | messages:
+ msg61476 |
| 2008-01-20 11:18:08 | georg.brandl | set | assignee: pje -> gvanrossum messages:
+ msg61270 nosy:
+ gvanrossum |
| 2006-04-19 21:39:28 | collinwinter | create | |
|