[New-bugs-announce] [issue15657] Error in Python 3 docs for PyMethodDef

Sandro Tosi report at bugs.python.org
Tue Aug 14 21:02:46 CEST 2012


New submission from Sandro Tosi:

Hello,
it has been reported at http://mail.python.org/pipermail/docs/2012-April/008215.html but given it raises some question whether it's a bug in the doc or in the code, i'd rather report the issue here and hear what other think:

>>>
In the Python 3.2.2 documentation (and earlier Python 3 versions), in
the Python/C API Reference Manual, chapter Object Implementation
Support, the documentation for PyMethodDef says:

  The ml_flags field is a bitfield which can include the following
  flags. The individual flags indicate either a calling convention or a
  binding convention. Of the calling convention flags, only METH_VARARGS
  and METH_KEYWORDS can be combined (but note that METH_KEYWORDS alone
  is equivalent to METH_VARARGS | METH_KEYWORDS).

The bit in the parenthetical is incorrect.  If you take a look at
PyCFunction_Call in Objects/methodobject.c, you will find a switch for
METH_VARARGS | METH_KEYWORDS, but no switch for METH_KEYWORDS.  Hence,
using METH_KEYWORDS will land you with a SystemError that complains
about METH_OLDARGS.

This is either a bug in the documentation, or a bug in Python.  In this
case, since the code has persisted through three major revisions of
Python 3, I suggest that the bug _is_ in the documentation (whether it
should be or not), since changing the code for this at this late date
means a programmer has to use METH_VARARGS | METH_KEYWORDS anyway for
compatibility.

It may be work pointing out specifically in the documentation that just
using METH_KEYWORDS will not work.
<<<

----------
assignee: docs at python
components: Documentation
messages: 168226
nosy: docs at python, sandro.tosi
priority: normal
severity: normal
stage: patch review
status: open
title: Error in Python 3 docs for PyMethodDef
versions: Python 3.2, Python 3.3

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


More information about the New-bugs-announce mailing list