-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-30534: Fix error messages when pass keyword arguments #1901
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
bpo-30534: Fix error messages when pass keyword arguments #1901
Conversation
to functions implemented in C that don't support this.
vstinner
left a comment
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.
LGTM, I also like included cleanup changes ;-)
On the issue, I requested unit tests. But I also proposed to change the error message, so we write tests later, when we agree on what should be done.
|
|
||
| def test_varargs0_kw(self): | ||
| self.assertRaises(TypeError, {}.__contains__, x=2) | ||
|
|
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.
You may keep this test for other Python implementations. (This test doesn't check the error message.)
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.
This is a duplicate of the following test.
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.
Oh ok, you are right.
Lib/test/test_itertools.py
Outdated
| except TypeError as err: | ||
| # we expect type errors because of wrong argument count | ||
| self.assertNotIn("does not take keyword arguments", err.args[0]) | ||
| print(repr(err)) |
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.
Remove print()?
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.
Done.
Objects/call.c
Outdated
| break; | ||
|
|
||
| case METH_VARARGS: | ||
| if (!(flags & METH_KEYWORDS) && nkwargs) { |
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 "!(flags & METH_KEYWORDS)" still 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.
Not needed. Removed.
vstinner
left a comment
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.
LGTM.
|
Thank you for your review @Haypo. |
to functions implemented in C that don't support this.