-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-30627: Fix error message when keyword arguments are used #2115
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
Conversation
@@ -1832,9 +1832,6 @@ s_pack(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) | |||
"pack expected %zd items for packing (got %zd)", soself->s_len, nargs); | |||
return NULL; | |||
} | |||
if (!_PyArg_NoStackKeywords("pack", kwnames)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now Struct.pack()
just ignores keyword arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I did not know this could be called via a different path. Thanks for spotting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR, thanks for catching this!
@@ -2131,6 +2131,10 @@ pack(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) | |||
PyObject *s_object = NULL; | |||
PyObject *format, *result; | |||
|
|||
if (!_PyArg_NoStackKeywords("pack", kwnames)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is needed if we want the pack
(and pack_into
) function to have the same behavior as other function, ie checking for (unsupported) keyword arguments is the first check we perform. If we remove it, the tests test_varargs8_kw
and test_varargs9_kw
fail with error "missing format argument" as the check for keyword happened afterward (in the "s_"-prefixed functions).
I'm happy to get rid of the check and remove/update the test if you think it is better.
Thanks for your feedback!
No description provided.