[New-bugs-announce] [issue13026] Dis module - documentation of MAKE_FUNCTION

Arnaud Delobelle report at bugs.python.org
Thu Sep 22 00:02:38 CEST 2011


New submission from Arnaud Delobelle <arnodel at googlemail.com>:

The description of the opcode MAKE_FUNCTION in the dis module document is out of date.  It still describes the 2.X version of the opcode:

"""
MAKE_FUNCTION(argc)
Pushes a new function object on the stack. TOS is the code associated with the function. The function object is defined to have argc default parameters, which are found below TOS.
"""

According to http://hg.python.org/cpython/file/default/Python/ceval.c#l2684:


 2684             int posdefaults = oparg & 0xff;
 2685             int kwdefaults = (oparg>>8) & 0xff;
 2686             int num_annotations = (oparg >> 16) & 0x7fff;

So the documentation should read something like

"""
MAKE_FUNCTION(argc)
Pushes a new function object on the stack. TOS is the code associated with the function. The function object is defined to have argc & 0xFF positional default parameters, (argc >> 8) & 0xFF keyword only default parameters, and (argc >> 16) & 0x7FFF parameter annotations which are push below TOS in this order. For each keyword only default, the name of the parameter is pushed just below its default value. On top of all the annotations, a tuple is pushed listing the parameter names for these annotations.
"""

----------
assignee: docs at python
components: Documentation
messages: 144393
nosy: arno, docs at python, terry.reedy
priority: normal
severity: normal
status: open
title: Dis module - documentation of MAKE_FUNCTION
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13026>
_______________________________________


More information about the New-bugs-announce mailing list