Patches item #1473257, was opened at 2006-04-19 21:39 Message generated for change (Settings changed) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1473257&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core (C code) Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Collin Winter (collinwinter) >Assigned to: Phillip J. Eby (pje) Summary: Add a gi_code attr to generators Initial Comment: 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. ---------------------------------------------------------------------- Comment By: Collin Winter (collinwinter) Date: 2006-04-29 21:11 Message: Logged In: YES user_id=1344176 I've updated the patch; it's now against SVN r45808. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1473257&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
