New submission from Manuel Vazquez Acosta <[email protected]>:
The documentation of the dis module says that:
CALL_FUNCTION_VAR (argc)
Calls a function. *argc* is interpreted as in CALL_FUNCTION. The
top elements on the stack are the keyword arguments, followed by the
variable argument list, and then the positional arguments.
However, inspecting the how ``f(b=1, *args)`` is actually compiled shows a
different order:
>>> import dis
>>> dis.dis(compile('f(b=1, *args)', '<>', 'eval'))
1 0 LOAD_NAME 0 (f)
3 LOAD_NAME 1 (args)
6 LOAD_CONST 0 ('b')
9 LOAD_CONST 1 (1)
12 CALL_FUNCTION_VAR 256 (0 positional, 1 keyword pair)
15 RETURN_VALUE
Notice that the top of the stack contains the explicit keyword arguments.
The documentation of CALL_FUNCTION_VAR_KW is also incorrect.
----------
assignee: -> docs@python
components: +Documentation
nosy: +docs@python
title: CALL_FUNCTION_VAR -> Wrong order of stack for CALL_FUNCTION_VAR and
CALL_FUNCTION_VAR_KW
versions: +Python 3.5
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33216>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com