bpo-30627: Fix error message when keyword arguments are used#2115
bpo-30627: Fix error message when keyword arguments are used#2115serhiy-storchaka merged 3 commits intopython:masterfrom SylvainDe:bpo30600-bis
Conversation
| "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.
Now Struct.pack() just ignores keyword arguments.
There was a problem hiding this comment.
Indeed, I did not know this could be called via a different path. Thanks for spotting this.
There was a problem hiding this comment.
I've updated the PR, thanks for catching this!
| PyObject *s_object = NULL; | ||
| PyObject *format, *result; | ||
|
|
||
| if (!_PyArg_NoStackKeywords("pack", kwnames)) { |
There was a problem hiding this comment.
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.