Skip to content

Commit 0d805b9

Browse files
chgnrdvhugovkblurb-it[bot]
authored
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>
1 parent 732532b commit 0d805b9

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Diff for: Doc/library/cmdline.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The following modules have a command-line interface.
1212
* :ref:`compileall <compileall-cli>`
1313
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
1414
* :ref:`difflib <difflib-interface>`
15-
* :mod:`dis`
15+
* :ref:`dis <dis-cli>`
1616
* :mod:`doctest`
1717
* :mod:`!encodings.rot_13`
1818
* :mod:`ensurepip`

Diff for: Doc/library/dis.rst

+26
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@ the following command can be used to display the disassembly of
6363

6464
(The "2" is a line number).
6565

66+
.. _dis-cli:
67+
68+
Command-line interface
69+
----------------------
70+
71+
The :mod:`dis` module can be invoked as a script from the command line:
72+
73+
.. code-block:: sh
74+
75+
python -m dis [-h] [-C] [infile]
76+
77+
The following options are accepted:
78+
79+
.. program:: dis
80+
81+
.. cmdoption:: -h, --help
82+
83+
Display usage and exit.
84+
85+
.. cmdoption:: -C, --show-caches
86+
87+
Show inline caches.
88+
89+
If :file:`infile` is specified, its disassembled code will be written to stdout.
90+
Otherwise, disassembly is performed on compiled source code recieved from stdin.
91+
6692
Bytecode analysis
6793
-----------------
6894

Diff for: Lib/dis.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,7 @@ def dis(self):
896896
return output.getvalue()
897897

898898

899-
def _test():
900-
"""Simple test program to disassemble a file."""
899+
def main():
901900
import argparse
902901

903902
parser = argparse.ArgumentParser()
@@ -911,4 +910,4 @@ def _test():
911910
dis(code, show_caches=args.show_caches)
912911

913912
if __name__ == "__main__":
914-
_test()
913+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:mod:`dis` module command-line interface is now mentioned in documentation.

0 commit comments

Comments
 (0)