From 4cc1070176f404f7c2eeb96f99b8d4168c07ae4b Mon Sep 17 00:00:00 2001 From: Radislav Chugunov Date: Sat, 2 Sep 2023 21:34:15 +0300 Subject: [PATCH 01/12] Document dis module CLI, rename '_test' function to 'main' dis module has CLI, but it is not documented and declared as 'test program' in source code. This patch mentions CLI in documentation and renames the function where it is implemented. --- Doc/library/dis.rst | 21 +++++++++++++++++++++ Lib/dis.py | 5 ++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 6cd5f181c8433a..0389f50a75ae33 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -63,6 +63,27 @@ the following command can be used to display the disassembly of (The "2" is a line number). +Command-line interface +----------------- + +The :mod:`dis` module can be invoked as a script from the command line. +It is as simple as: + +.. code-block:: sh + + python -m dis [-h] [infile] + +The following options are accepted: + +.. program:: dis + +.. cmdoption:: -h, --help + + Display usage and exit. + +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 ----------------- diff --git a/Lib/dis.py b/Lib/dis.py index 7e4792e8a8dc62..feb1b2a73e4944 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -896,8 +896,7 @@ def dis(self): return output.getvalue() -def _test(): - """Simple test program to disassemble a file.""" +def main(): import argparse parser = argparse.ArgumentParser() @@ -909,4 +908,4 @@ def _test(): dis(code) if __name__ == "__main__": - _test() + main() From c7218eea29f1148035073ec12c06a8a860712642 Mon Sep 17 00:00:00 2001 From: Radislav Chugunov Date: Sat, 2 Sep 2023 21:47:35 +0300 Subject: [PATCH 02/12] fix title underline --- Doc/library/dis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 0389f50a75ae33..ac56befd07c143 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -64,7 +64,7 @@ the following command can be used to display the disassembly of (The "2" is a line number). Command-line interface ------------------ +---------------------- The :mod:`dis` module can be invoked as a script from the command line. It is as simple as: From 19ef422f819c9ff37cd600bff14a31bfbcdb1405 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 2 Sep 2023 18:48:46 +0000 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst diff --git a/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst b/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst new file mode 100644 index 00000000000000..322591bc772634 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst @@ -0,0 +1 @@ +:mod:`dis` module command line interface is now mentioned in documentation. From 74c9e7484ba2cd751f170952523e973952ea1d5a Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:42:38 +0300 Subject: [PATCH 04/12] Delete Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst --- .../next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst diff --git a/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst b/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst deleted file mode 100644 index 322591bc772634..00000000000000 --- a/Misc/NEWS.d/next/Library/2023-09-02-18-48-44.gh-issue-108826.KG7abS.rst +++ /dev/null @@ -1 +0,0 @@ -:mod:`dis` module command line interface is now mentioned in documentation. From b77c81363882c9e6d468285659716afa150cb447 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 3 Sep 2023 13:43:51 +0000 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst b/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst new file mode 100644 index 00000000000000..322591bc772634 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst @@ -0,0 +1 @@ +:mod:`dis` module command line interface is now mentioned in documentation. From fca2c549f0c6d448d4b08425cf8357d11dba17ed Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:22:11 +0300 Subject: [PATCH 06/12] Update Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst Co-authored-by: Hugo van Kemenade --- .../2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst b/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst index 322591bc772634..139b8f3457930c 100644 --- a/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst +++ b/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst @@ -1 +1 @@ -:mod:`dis` module command line interface is now mentioned in documentation. +:mod:`dis` module command-line interface is now mentioned in documentation. From 5d60cbe98df5b16c534bd08e78b5f007ce3d9ed5 Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:22:32 +0300 Subject: [PATCH 07/12] Update Doc/library/dis.rst Co-authored-by: Hugo van Kemenade --- Doc/library/dis.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index ac56befd07c143..14f70bf32d390f 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -66,8 +66,7 @@ the following command can be used to display the disassembly of Command-line interface ---------------------- -The :mod:`dis` module can be invoked as a script from the command line. -It is as simple as: +The :mod:`dis` module can be invoked as a script from the command line: .. code-block:: sh From 92da103020df64320457f612e1d31f6f0a962b87 Mon Sep 17 00:00:00 2001 From: Radislav Chugunov Date: Tue, 10 Oct 2023 23:47:29 +0300 Subject: [PATCH 08/12] link cmdline docs to dis docs CLI section --- Doc/library/cmdline.rst | 2 +- Doc/library/dis.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/cmdline.rst b/Doc/library/cmdline.rst index 4a295e069287d8..b2e33629de3ee6 100644 --- a/Doc/library/cmdline.rst +++ b/Doc/library/cmdline.rst @@ -12,7 +12,7 @@ The following modules have a command-line interface. * :ref:`compileall ` * :mod:`cProfile`: see :ref:`profile ` * :ref:`difflib ` -* :mod:`dis` +* :mod:`dis ` * :mod:`doctest` * :mod:`!encodings.rot_13` * :mod:`ensurepip` diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index f11a83d1789bf8..e44177726d62b2 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -63,6 +63,8 @@ the following command can be used to display the disassembly of (The "2" is a line number). +.. _dis-cli: + Command-line interface ---------------------- From 7b622f92b70e24d2314bfaf60ddbed2ff5a627f9 Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:00:25 +0300 Subject: [PATCH 09/12] fix dis ref in cmdline docs --- Doc/library/cmdline.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/cmdline.rst b/Doc/library/cmdline.rst index b2e33629de3ee6..b2379befeffcba 100644 --- a/Doc/library/cmdline.rst +++ b/Doc/library/cmdline.rst @@ -12,7 +12,7 @@ The following modules have a command-line interface. * :ref:`compileall ` * :mod:`cProfile`: see :ref:`profile ` * :ref:`difflib ` -* :mod:`dis ` +* :ref:`dis ` * :mod:`doctest` * :mod:`!encodings.rot_13` * :mod:`ensurepip` From 9c4540d37c83723bd2797e479e5bb30053fe4f7a Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:46:28 +0300 Subject: [PATCH 10/12] document --show-caches cmd option --- Doc/library/dis.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 654570b024d768..a6eaca6c8b93d6 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -78,6 +78,10 @@ The following options are accepted: .. program:: dis +.. cmdoption:: -C, --show-caches + + Show inline caches. + .. cmdoption:: -h, --help Display usage and exit. From 544e908346b97398118433715d883a8aa523ce6b Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:58:27 +0300 Subject: [PATCH 11/12] Update dis.rst --- Doc/library/dis.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index a6eaca6c8b93d6..9080e1a73d50c4 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -72,7 +72,7 @@ The :mod:`dis` module can be invoked as a script from the command line: .. code-block:: sh - python -m dis [-h] [infile] + python -m dis [-h] [-C] [infile] The following options are accepted: From 489da898fe9a013937705215b39758762d3f4b02 Mon Sep 17 00:00:00 2001 From: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Date: Wed, 11 Oct 2023 01:00:00 +0300 Subject: [PATCH 12/12] Update dis.rst --- Doc/library/dis.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 9080e1a73d50c4..1f773b7b337fa3 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -78,14 +78,14 @@ The following options are accepted: .. program:: dis -.. cmdoption:: -C, --show-caches - - Show inline caches. - .. 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.