mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
gh-108826: Document dis module CLI and rename _test function to main (#108827)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
732532b0af
commit
0d805b998d
4 changed files with 30 additions and 4 deletions
|
|
@ -12,7 +12,7 @@ The following modules have a command-line interface.
|
|||
* :ref:`compileall <compileall-cli>`
|
||||
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
|
||||
* :ref:`difflib <difflib-interface>`
|
||||
* :mod:`dis`
|
||||
* :ref:`dis <dis-cli>`
|
||||
* :mod:`doctest`
|
||||
* :mod:`!encodings.rot_13`
|
||||
* :mod:`ensurepip`
|
||||
|
|
|
|||
|
|
@ -63,6 +63,32 @@ the following command can be used to display the disassembly of
|
|||
|
||||
(The "2" is a line number).
|
||||
|
||||
.. _dis-cli:
|
||||
|
||||
Command-line interface
|
||||
----------------------
|
||||
|
||||
The :mod:`dis` module can be invoked as a script from the command line:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
python -m dis [-h] [-C] [infile]
|
||||
|
||||
The following options are accepted:
|
||||
|
||||
.. program:: dis
|
||||
|
||||
.. cmdoption:: -h, --help
|
||||
|
||||
Display usage and exit.
|
||||
|
||||
.. cmdoption:: -C, --show-caches
|
||||
|
||||
Show inline caches.
|
||||
|
||||
If :file:`infile` is specified, its disassembled code will be written to stdout.
|
||||
Otherwise, disassembly is performed on compiled source code recieved from stdin.
|
||||
|
||||
Bytecode analysis
|
||||
-----------------
|
||||
|
||||
|
|
|
|||
|
|
@ -896,8 +896,7 @@ class Bytecode:
|
|||
return output.getvalue()
|
||||
|
||||
|
||||
def _test():
|
||||
"""Simple test program to disassemble a file."""
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
@ -911,4 +910,4 @@ def _test():
|
|||
dis(code, show_caches=args.show_caches)
|
||||
|
||||
if __name__ == "__main__":
|
||||
_test()
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
:mod:`dis` module command-line interface is now mentioned in documentation.
|
||||
Loading…
Add table
Add a link
Reference in a new issue