This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author freakboy3742
Recipients docs@python, freakboy3742
Date 2015-12-11.04:13:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1449807235.86.0.17166679506.issue25836@psf.upfronthosting.co.za>
In-reply-to
Content
Refs Issue16554, Issue13026, Issue14349, and probably others.

The documentation for the interpretation of the argc argument to MAKE_FUNCTION in Doc/library/dis.rst is incorrect. 

As of 13 August 2015, the docs say:

"""
Pushes a new function object on the stack.  From bottom to top, the consumed
stack must consist of:

   * ``argc & 0xFF`` default argument objects in positional order
   * ``(argc >> 8) & 0xFF`` pairs of name and default argument, with the name
     just below the object on the stack, for keyword-only parameters
   * ``(argc >> 16) & 0x7FFF`` parameter annotation objects
   * a tuple listing the parameter names for the annotations (only if there are
     ony annotation objects)
   * the code associated with the function (at TOS1)
   * the :term:`qualified name` of the function (at TOS)
"""

However, this doesn't capture the fact that:

 * if there are annotations, the number of default arguments returned by `argc & 0xFF` must be reduced by `(argc >> 16) & 0x7FFF`

 * The value `(argc >> 16) & 0x7FFF` for the number of annotations *includes* the "extra" entry for the tuple describing which arguments the annotations apply to. This means that `(argc >> 16) & 0x7FFF` will be either 0, or 2+; it can't be 1 (because if you have one annotation, you must also have a tuple describing which arguments is annotated).
History
Date User Action Args
2015-12-11 04:13:55freakboy3742setrecipients: + freakboy3742, docs@python
2015-12-11 04:13:55freakboy3742setmessageid: <1449807235.86.0.17166679506.issue25836@psf.upfronthosting.co.za>
2015-12-11 04:13:55freakboy3742linkissue25836 messages
2015-12-11 04:13:54freakboy3742create