Skip to content

Commit 8698b34

Browse files
cfbolzmethane
authored andcommitted
improve the documentation of the LOAD_METHOD and CALL_METHOD (GH-18079)
1 parent 8d57a41 commit 8698b34

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
@@ -1140,22 +1140,24 @@ All of the following opcodes use their arguments.
11401140

11411141
.. opcode:: LOAD_METHOD (namei)
11421142

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

11491150
.. versionadded:: 3.7
11501151

11511152

11521153
.. opcode:: CALL_METHOD (argc)
11531154

1154-
Calls a method. *argc* is number of positional arguments.
1155+
Calls a method. *argc* is the number of positional arguments.
11551156
Keyword arguments are not supported. This opcode is designed to be used
11561157
with :opcode:`LOAD_METHOD`. Positional arguments are on top of the stack.
1157-
Below them, two items described in :opcode:`LOAD_METHOD` on the stack.
1158-
All of them are popped and return value is pushed.
1158+
Below them, the two items described in :opcode:`LOAD_METHOD` are on the
1159+
stack (either ``self`` and an unbound method object or ``NULL`` and an
1160+
arbitrary callable). All of them are popped and the return value is pushed.
11591161

11601162
.. versionadded:: 3.7
11611163

0 commit comments

Comments
 (0)