diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-07-28 10:00:01 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-07-28 10:00:01 (GMT) |
commit | e8c45d6d0eda74a8f13dcac9d0c593bbcb21e38b (patch) | |
tree | 0f84fdc0cf870e81fd8f1c4efa3bfdca555b55cc /Doc/library | |
parent | 77578204d6aeb89a9ee8365f8fb28ce18aa2eb7c (diff) | |
download | cpython-e8c45d6d0eda74a8f13dcac9d0c593bbcb21e38b.zip cpython-e8c45d6d0eda74a8f13dcac9d0c593bbcb21e38b.tar.gz cpython-e8c45d6d0eda74a8f13dcac9d0c593bbcb21e38b.tar.bz2 |
Close #13266: Add inspect.unwrap
Initial patch by Daniel Urban and Aaron Iles
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/inspect.rst | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 40f482b..af6c96b 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -797,6 +797,23 @@ Classes and functions .. versionadded:: 3.3 +.. function:: unwrap(func, *, stop=None) + + Get the object wrapped by *func*. It follows the chain of :attr:`__wrapped__` + attributes returning the last object in the chain. + + *stop* is an optional callback accepting an object in the wrapper chain + as its sole argument that allows the unwrapping to be terminated early if + the callback returns a true value. If the callback never returns a true + value, the last object in the chain is returned as usual. For example, + :func:`signature` uses this to stop unwrapping if any object in the + chain has a ``__signature__`` attribute defined. + + :exc:`ValueError` is raised if a cycle is encountered. + + .. versionadded:: 3.4 + + .. _inspect-stack: The interpreter stack |