-
-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in Python 3 docs for PyMethodDef #59862
Comments
Hello,
The ml_flags field is a bitfield which can include the following The bit in the parenthetical is incorrect. If you take a look at This is either a bug in the documentation, or a bug in Python. In this It may be work pointing out specifically in the documentation that just |
I think we can change PyCFunction_Call to accept METH_KEYWORDS as alias for METH_VARARGS | METH_KEYWORDS. |
I just ran into this too. |
We should fix the code for 3.2 through 3.4, but change the docs for 3.2 and 3.3 to remove the parenthetical note. For 3.4 we can leave the parenthetical note but say this is new in 3.4 (or maybe, that it doesn't actually work in some versions < 3.4). I agree that for code to work consistently across all Python 3.2 and 3.3 microversions, extension code is going to have to include both flags anyway. |
Appears to be a duplicate of bpo-11587 but better explanation here |
Here is a patch for Python 3.5. |
In 3.5 it would be better to make METH_KEYWORDS == METH_VARARGS | METH_KEYWORDS. Current definition: #define METH_VARARGS 0x0001
#define METH_KEYWORDS 0x0002 Should be: #define METH_VARARGS 0x0001
#define METH_KEYWORDS 0x0003 But it can't be applied in maintained releases. In 3.4 and 2.7 we should add explicit test as in the patch or change the documentation. If fix the code rather than documentation in 3.4 and 2.7, then the versionchanged directive in 3.5 shouldn't be added. |
I'm going to delete
from Doc/c-api/structures.rst in 3.5. Then change the value of METH_KEYWORDS from 0x0002 to 0x0003 in 3.6. Thanks for the review Serhiy. |
New changeset 367b3f41710a by Berker Peksag in branch '3.5': New changeset 7fa4986d8218 by Berker Peksag in branch 'default': |
New changeset f520ae3b537b by Berker Peksag in branch '2.7': |
Here is a patch. |
. The remaining issue15657_36.diff patch looks out of date. There is a _PyCFunction_FastCallDict() function that appears to also need adjusting. But instead of changing the value of METH_KEYWORDS, wouldn’t it be safer to just accept METH_KEYWORDS (= 2) on its own as a valid value? This is what Python 2 does. Essentially, revert the first hunk of https://hg.python.org/cpython/diff/b7bfa780a882/Objects/methodobject.c but without METH_OLDARGS, whose value was zero anyway. BTW, the statement did not need to be removed in Python 2, but IMO it’s fine now without the statment. The statement was added in revision 1564c6839e6b. |
New changeset d7d2d24003f5 by Martin Panter in branch '3.5': New changeset c140e72492a4 by Martin Panter in branch '3.6': New changeset 021fd2ff7ca4 by Martin Panter in branch '3.6': New changeset 1058e151049a by Martin Panter in branch 'default': |
I think this bug has been fixed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: