From fa4ba05b37dedfbb346e98a2176a8b86470a2371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Tue, 3 Apr 2018 15:43:04 -0400 Subject: [PATCH 1/3] Correct the doc of CALL_FUNCTION_VAR and CALL_FUNCTION_VAR_KW. The order of the elements in the stack was incorrect. It seems that, in general (for all CALL_FUNCTION opcodes), the correct order is (from bottom to top): function positional arguments [star arg tuple] keyword arguments [keyword dictionary] CALL_FUNCTION[_..] Fixes [bug 33216](https://bugs.python.org/issue33216). --- Doc/library/dis.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 186aab40f636f9..3a87ed28fd2dae 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1021,8 +1021,8 @@ the more significant byte last. .. opcode:: CALL_FUNCTION_VAR (argc) Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The - top element on the stack contains the variable argument list, followed by - keyword and positional arguments. + top elements on the stack are the keyword arguments, followed by the + variable argument list, and then the positional arguments. .. opcode:: CALL_FUNCTION_KW (argc) @@ -1035,9 +1035,9 @@ the more significant byte last. .. opcode:: CALL_FUNCTION_VAR_KW (argc) Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The - top element on the stack contains the keyword arguments dictionary, followed - by the variable-arguments tuple, followed by explicit keyword and positional - arguments. + top element on the stack contains the keyword arguments dictionary, + followed by explicit keyword arguments, then the variable-arguments tuple, + and finally by the positional arguments. .. opcode:: HAVE_ARGUMENT From 8d1f0fa485060246d1e3f5304f8aeb5907a4ebb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Mon, 30 Apr 2018 16:45:31 -0400 Subject: [PATCH 2/3] Log changes in the stack order for CALL_FUNCTION_VAR*. --- Doc/library/dis.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 3a87ed28fd2dae..4e0fa1e3591b8a 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1024,6 +1024,8 @@ the more significant byte last. top elements on the stack are the keyword arguments, followed by the variable argument list, and then the positional arguments. + .. versionchanged:: 3.5 + The order of elements in the stack was changed. .. opcode:: CALL_FUNCTION_KW (argc) @@ -1039,6 +1041,8 @@ the more significant byte last. followed by explicit keyword arguments, then the variable-arguments tuple, and finally by the positional arguments. + .. versionchanged:: 3.5 + The order of elements in the stack was changed. .. opcode:: HAVE_ARGUMENT From 4c086cb5fd1aa3221c3ce23f6b8ff840fb7e5ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Fri, 25 May 2018 09:39:03 -0400 Subject: [PATCH 3/3] Rewrite the CALL_FUNCTION_VAR_*. Use 'var-keyword' and 'var-positional' to better specify the items in the stack. Describe each opcode by stating the difference with CALL_FUNCTION. --- Doc/library/dis.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst index 4e0fa1e3591b8a..fb0cbbb7bbd7bd 100644 --- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -1020,9 +1020,10 @@ the more significant byte last. .. opcode:: CALL_FUNCTION_VAR (argc) - Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The - top elements on the stack are the keyword arguments, followed by the - variable argument list, and then the positional arguments. + Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The + difference with :opcode:`CALL_FUNCTION`, is that ``CALL_FUNCTION_VAR`` + finds the var-positional argument below all the keyword parameters, but + above all positional parameters. .. versionchanged:: 3.5 The order of elements in the stack was changed. @@ -1037,9 +1038,8 @@ the more significant byte last. .. opcode:: CALL_FUNCTION_VAR_KW (argc) Calls a function. *argc* is interpreted as in :opcode:`CALL_FUNCTION`. The - top element on the stack contains the keyword arguments dictionary, - followed by explicit keyword arguments, then the variable-arguments tuple, - and finally by the positional arguments. + opcode finds the var-keyword argument at the top of the stack; and below, + the opcode finds the same items :opcode:`CALL_FUNCTION_VAR` does. .. versionchanged:: 3.5 The order of elements in the stack was changed.