Skip to content

Conversation

@SylvainDe
Copy link
Contributor

No description provided.

"pack expected %zd items for packing (got %zd)", soself->s_len, nargs);
return NULL;
}
if (!_PyArg_NoStackKeywords("pack", kwnames)) {
Copy link
Member

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.

Copy link
Contributor Author

@SylvainDe SylvainDe Jun 12, 2017

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.

Copy link
Contributor Author

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!

PyObject *s_object = NULL;
PyObject *format, *result;

if (!_PyArg_NoStackKeywords("pack", kwnames)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

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!

@serhiy-storchaka serhiy-storchaka merged commit 96c7c06 into python:master Jun 15, 2017
@serhiy-storchaka serhiy-storchaka changed the title bpo-20627: Fix error message when keyword arguments are used bpo-30627: Fix error message when keyword arguments are used Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants