summaryrefslogtreecommitdiffstats
path: root/Doc/library/dis.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-06-11 11:09:39 (GMT)
committerGitHub <noreply@github.com>2017-06-11 11:09:39 (GMT)
commit1efbf92e90ed2edf3f5bb5323340b26f318ff61e (patch)
treeb3dbf9eede1f4c0094c8c8dcf0a02523406b3130 /Doc/library/dis.rst
parentfdfca5f0ffa831a3365cbabf9ed8fd05e9c4da49 (diff)
downloadcpython-1efbf92e90ed2edf3f5bb5323340b26f318ff61e.zip
cpython-1efbf92e90ed2edf3f5bb5323340b26f318ff61e.tar.gz
cpython-1efbf92e90ed2edf3f5bb5323340b26f318ff61e.tar.bz2
bpo-11822: Improve disassembly to show embedded code objects. (#1844)
The depth argument limits recursion.
Diffstat (limited to 'Doc/library/dis.rst')
-rw-r--r--Doc/library/dis.rst13
1 files changed, 11 insertions, 2 deletions
diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index f82dc40..bc32380 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -138,23 +138,32 @@ operation is being performed, so the intermediate analysis object isn't useful:
Added *file* parameter.
-.. function:: dis(x=None, *, file=None)
+.. function:: dis(x=None, *, file=None, depth=None)
Disassemble the *x* object. *x* can denote either a module, a class, a
method, a function, a generator, a code object, a string of source code or
a byte sequence of raw bytecode. For a module, it disassembles all functions.
For a class, it disassembles all methods (including class and static methods).
For a code object or sequence of raw bytecode, it prints one line per bytecode
- instruction. Strings are first compiled to code objects with the :func:`compile`
+ instruction. It also recursively disassembles nested code objects (the code
+ of comprehensions, generator expressions and nested functions, and the code
+ used for building nested classes).
+ Strings are first compiled to code objects with the :func:`compile`
built-in function before being disassembled. If no object is provided, this
function disassembles the last traceback.
The disassembly is written as text to the supplied *file* argument if
provided and to ``sys.stdout`` otherwise.
+ The maximal depth of recursion is limited by *depth* unless it is ``None``.
+ ``depth=0`` means no recursion.
+
.. versionchanged:: 3.4
Added *file* parameter.
+ .. versionchanged:: 3.7
+ Implemented recursive disassembling and added *depth* parameter.
+
.. function:: distb(tb=None, *, file=None)