summaryrefslogtreecommitdiffstats
path: root/Doc/library/inspect.rst
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-06-23 09:39:55 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-06-23 09:39:55 (GMT)
commit2f92e54507cd4a76978133c10bf32cbdef90cd37 (patch)
tree6a027fec78404e9cce88c8ef892f6a7b1b1d423b /Doc/library/inspect.rst
parent970da4549ab78ad6f89dd0cce0d2defc771e1c72 (diff)
downloadcpython-2f92e54507cd4a76978133c10bf32cbdef90cd37.zip
cpython-2f92e54507cd4a76978133c10bf32cbdef90cd37.tar.gz
cpython-2f92e54507cd4a76978133c10bf32cbdef90cd37.tar.bz2
Close #13062: Add inspect.getclosurevars to simplify testing stateful closures
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r--Doc/library/inspect.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index 611f780..04b724b 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -497,6 +497,22 @@ Classes and functions
.. versionadded:: 3.2
+.. function:: getclosurevars(func)
+
+ Get the mapping of external name references in a Python function or
+ method *func* to their current values. A
+ :term:`named tuple` ``ClosureVars(nonlocals, globals, builtins, unbound)``
+ is returned. *nonlocals* maps referenced names to lexical closure
+ variables, *globals* to the function's module globals and *builtins* to
+ the builtins visible from the function body. *unbound* is the set of names
+ referenced in the function that could not be resolved at all given the
+ current module globals and builtins.
+
+ :exc:`TypeError` is raised if *func* is not a Python function or method.
+
+ .. versionadded:: 3.3
+
+
.. _inspect-stack:
The interpreter stack