[New-bugs-announce] [issue13062] Introspection generator and function closure state
Nick Coghlan
report at bugs.python.org
Thu Sep 29 19:43:10 CEST 2011
New submission from Nick Coghlan <ncoghlan at gmail.com>:
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).
----------
messages: 144606
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: Introspection generator and function closure state
type: feature request
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13062>
_______________________________________
More information about the New-bugs-announce
mailing list