[Python-checkins] improve the documentation of the LOAD_METHOD and CALL_METHOD (GH-18079)

Miss Islington (bot) webhook-mailer at python.org
Mon Jan 20 20:12:12 EST 2020


https://github.com/python/cpython/commit/070e68a59d4a3e36085957eea83b79181bd1e0ba
commit: 070e68a59d4a3e36085957eea83b79181bd1e0ba
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-01-20T17:12:07-08:00
summary:

improve the documentation of the LOAD_METHOD and CALL_METHOD (GH-18079)

(cherry picked from commit 8698b34b68065b80bd9bd18b8decb425208fa386)

Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>

files:
M Doc/library/dis.rst

diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst
index 39a3e130afd3e..b1404af9c00eb 100644
--- a/Doc/library/dis.rst
+++ b/Doc/library/dis.rst
@@ -1176,22 +1176,24 @@ All of the following opcodes use their arguments.
 
 .. opcode:: LOAD_METHOD (namei)
 
-   Loads a method named ``co_names[namei]`` from TOS object. TOS is popped and
-   method and TOS are pushed when interpreter can call unbound method directly.
-   TOS will be used as the first argument (``self``) by :opcode:`CALL_METHOD`.
-   Otherwise, ``NULL`` and  method is pushed (method is bound method or
-   something else).
+   Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped.
+   This bytecode distinguishes two cases: if TOS has a method with the correct
+   name, the bytecode pushes the unbound method and TOS. TOS will be used as
+   the first argument (``self``) by :opcode:`CALL_METHOD` when calling the
+   unbound method. Otherwise, ``NULL`` and the object return by the attribute
+   lookup are pushed.
 
    .. versionadded:: 3.7
 
 
 .. opcode:: CALL_METHOD (argc)
 
-   Calls a method.  *argc* is number of positional arguments.
+   Calls a method.  *argc* is the number of positional arguments.
    Keyword arguments are not supported.  This opcode is designed to be used
    with :opcode:`LOAD_METHOD`.  Positional arguments are on top of the stack.
-   Below them, two items described in :opcode:`LOAD_METHOD` on the stack.
-   All of them are popped and return value is pushed.
+   Below them, the two items described in :opcode:`LOAD_METHOD` are on the
+   stack (either ``self`` and an unbound method object or ``NULL`` and an
+   arbitrary callable). All of them are popped and the return value is pushed.
 
    .. versionadded:: 3.7
 



More information about the Python-checkins mailing list