Skip to content

Commit e6c53dd

Browse files
hugovkblurb-it[bot]chgnrdv
authored
[3.12] gh-108826: Document dis module CLI and rename _test function to main (#108827) (#110681)
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> Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
1 parent 989aa44 commit e6c53dd

12 files changed

+95
-3
lines changed

Doc/library/asyncio.rst

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Additionally, there are **low-level** APIs for
5656
* :ref:`bridge <asyncio-futures>` callback-based libraries and code
5757
with async/await syntax.
5858

59+
.. _asyncio-cli:
60+
5961
You can experiment with an ``asyncio`` concurrent context in the REPL:
6062

6163
.. code-block:: pycon

Doc/library/cmdline.rst

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
++++++++++++++++++++++++++++++++++++
2+
Modules command-line interface (CLI)
3+
++++++++++++++++++++++++++++++++++++
4+
5+
The following modules have a command-line interface.
6+
7+
* :ref:`ast <ast-cli>`
8+
* :ref:`asyncio <asyncio-cli>`
9+
* :mod:`base64`
10+
* :ref:`calendar <calendar-cli>`
11+
* :mod:`code`
12+
* :ref:`compileall <compileall-cli>`
13+
* :mod:`cProfile`: see :ref:`profile <profile-cli>`
14+
* :ref:`difflib <difflib-interface>`
15+
* :ref:`dis <dis-cli>`
16+
* :mod:`doctest`
17+
* :mod:`!encodings.rot_13`
18+
* :mod:`ensurepip`
19+
* :mod:`filecmp`
20+
* :mod:`fileinput`
21+
* :mod:`ftplib`
22+
* :ref:`gzip <gzip-cli>`
23+
* :ref:`http.server <http-server-cli>`
24+
* :mod:`!idlelib`
25+
* :ref:`inspect <inspect-module-cli>`
26+
* :ref:`json.tool <json-commandline>`
27+
* :mod:`mimetypes`
28+
* :mod:`pdb`
29+
* :mod:`pickle`
30+
* :ref:`pickletools <pickletools-cli>`
31+
* :mod:`platform`
32+
* :mod:`poplib`
33+
* :ref:`profile <profile-cli>`
34+
* :mod:`pstats`
35+
* :ref:`py_compile <py_compile-cli>`
36+
* :mod:`pyclbr`
37+
* :mod:`pydoc`
38+
* :mod:`quopri`
39+
* :mod:`runpy`
40+
* :ref:`site <site-commandline>`
41+
* :ref:`sqlite3 <sqlite3-cli>`
42+
* :ref:`sysconfig <sysconfig-cli>`
43+
* :mod:`tabnanny`
44+
* :ref:`tarfile <tarfile-commandline>`
45+
* :mod:`!this`
46+
* :ref:`timeit <timeit-command-line-interface>`
47+
* :ref:`tokenize <tokenize-cli>`
48+
* :ref:`trace <trace-cli>`
49+
* :mod:`turtledemo`
50+
* :ref:`unittest <unittest-command-line-interface>`
51+
* :ref:`uuid <uuid-cli>`
52+
* :mod:`venv`
53+
* :mod:`webbrowser`
54+
* :ref:`zipapp <zipapp-command-line-interface>`
55+
* :ref:`zipfile <zipfile-commandline>`
56+
57+
See also the :ref:`Python command-line interface <using-on-general>`.

Doc/library/compileall.rst

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ have write permission to the library directories.
1616

1717
.. include:: ../includes/wasm-notavail.rst
1818

19+
.. _compileall-cli:
20+
1921
Command-line use
2022
----------------
2123

Doc/library/dis.rst

+22
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,28 @@ 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] [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+
If :file:`infile` is specified, its disassembled code will be written to stdout.
86+
Otherwise, disassembly is performed on compiled source code recieved from stdin.
87+
6688
Bytecode analysis
6789
-----------------
6890

Doc/library/gzip.rst

+2
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ Example of how to GZIP compress a binary string::
250250

251251
.. program:: gzip
252252

253+
.. _gzip-cli:
254+
253255
Command Line Interface
254256
----------------------
255257

Doc/library/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ the `Python Package Index <https://pypi.org>`_.
7373
language.rst
7474
windows.rst
7575
unix.rst
76+
cmdline.rst
7677
superseded.rst
7778
security_warnings.rst

Doc/library/pickletools.rst

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ are useful for Python core developers who are working on the :mod:`pickle`;
1717
ordinary users of the :mod:`pickle` module probably won't find the
1818
:mod:`pickletools` module relevant.
1919

20+
.. _pickletools-cli:
21+
2022
Command line usage
2123
------------------
2224

Doc/library/profile.rst

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ results to a file by specifying a filename to the :func:`run` function::
121121
The :class:`pstats.Stats` class reads profile results from a file and formats
122122
them in various ways.
123123

124+
.. _profile-cli:
125+
124126
The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script to
125127
profile another script. For example::
126128

Doc/library/py_compile.rst

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ byte-code cache files in the directory containing the source code.
125125
This option is useful when the ``.pycs`` are kept up to date by some
126126
system external to Python like a build system.
127127

128+
.. _py_compile-cli:
128129

129130
Command-Line Interface
130131
----------------------

Doc/library/sysconfig.rst

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ Other functions
427427

428428
Return the path of :file:`Makefile`.
429429

430+
.. _sysconfig-cli:
430431

431432
Using :mod:`sysconfig` as a script
432433
----------------------------------

Lib/dis.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ def dis(self):
790790
return output.getvalue()
791791

792792

793-
def _test():
794-
"""Simple test program to disassemble a file."""
793+
def main():
795794
import argparse
796795

797796
parser = argparse.ArgumentParser()
@@ -803,4 +802,4 @@ def _test():
803802
dis(code)
804803

805804
if __name__ == "__main__":
806-
_test()
805+
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)