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.

Author ncoghlan
Recipients ncoghlan
Date 2011-09-29.17:43:09
SpamBayes Score 0.0002660877
Marked as misclassified No
Message-id <1317318190.56.0.437971601638.issue13062@psf.upfronthosting.co.za>
In-reply-to
Content
Based on the python-ideas thread about closures, I realised there are two features the inspect module could offer to greatly simplify some aspects of testing closure and generator behaviour:

  inspect.getclosure(func)
    Returns a dictionary mapping closure references from the supplied function to their current values.

  inspect.getgeneratorlocals(generator)
    Returns the same result as would be reported by calling locals() in the generator's frame of execution

The former would just involve syncing up the names on the code object with the cell references on the function object, while the latter would be equivalent to doing generator.gi_frame.f_locals with some nice error checking for when the generator's frame is already gone (or the supplied object isn't a generator iterator).
History
Date User Action Args
2011-09-29 17:43:10ncoghlansetrecipients: + ncoghlan
2011-09-29 17:43:10ncoghlansetmessageid: <1317318190.56.0.437971601638.issue13062@psf.upfronthosting.co.za>
2011-09-29 17:43:09ncoghlanlinkissue13062 messages
2011-09-29 17:43:09ncoghlancreate