Skip to content

Commit d7b0118

Browse files
improve the documentation of the LOAD_METHOD and CALL_METHOD (GH-18079)
(cherry picked from commit 8698b34) Co-authored-by: Carl Friedrich Bolz-Tereick <[email protected]>
1 parent 3da8390 commit d7b0118

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Doc/library/dis.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,22 +1120,24 @@ All of the following opcodes use their arguments.
11201120

11211121
.. opcode:: LOAD_METHOD (namei)
11221122

1123-
Loads a method named ``co_names[namei]`` from TOS object. TOS is popped and
1124-
method and TOS are pushed when interpreter can call unbound method directly.
1125-
TOS will be used as the first argument (``self``) by :opcode:`CALL_METHOD`.
1126-
Otherwise, ``NULL`` and method is pushed (method is bound method or
1127-
something else).
1123+
Loads a method named ``co_names[namei]`` from the TOS object. TOS is popped.
1124+
This bytecode distinguishes two cases: if TOS has a method with the correct
1125+
name, the bytecode pushes the unbound method and TOS. TOS will be used as
1126+
the first argument (``self``) by :opcode:`CALL_METHOD` when calling the
1127+
unbound method. Otherwise, ``NULL`` and the object return by the attribute
1128+
lookup are pushed.
11281129

11291130
.. versionadded:: 3.7
11301131

11311132

11321133
.. opcode:: CALL_METHOD (argc)
11331134

1134-
Calls a method. *argc* is number of positional arguments.
1135+
Calls a method. *argc* is the number of positional arguments.
11351136
Keyword arguments are not supported. This opcode is designed to be used
11361137
with :opcode:`LOAD_METHOD`. Positional arguments are on top of the stack.
1137-
Below them, two items described in :opcode:`LOAD_METHOD` on the stack.
1138-
All of them are popped and return value is pushed.
1138+
Below them, the two items described in :opcode:`LOAD_METHOD` are on the
1139+
stack (either ``self`` and an unbound method object or ``NULL`` and an
1140+
arbitrary callable). All of them are popped and the return value is pushed.
11391141

11401142
.. versionadded:: 3.7
11411143

0 commit comments

Comments
 (0)