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 message incorrect when index is called with keyword argument ("[].index(x=2)") #74785
Comments
Issue found while trying to write tests for https://bugs.python.org/issue30592 . Issue related to http://bugs.python.org/issue30534 . The following code:
should raise the following error:
but currently raises:
This is easily reproduced with the following unit test: # AssertionError: "^index\(\) takes no keyword arguments$" does not match "index() takes at least 1 argument (0 given)"
def test_varargs4_kw(self):
msg = r"^index\(\) takes no keyword arguments$"
self.assertRaisesRegex(TypeError, msg, [].index, x=2) |
Good catch! This issue is similar to bpo-30534, but caused by generated code. The solution is easy: make Argument Clinic (Tools/clinic/clinic.py) generating _PyArg_NoStackKeywords() before _PyArg_ParseStack() and regenerate all generated by Argument Clinic code (make clinic). |
Can I give this a try or is anyone working on this already ? |
Yes, pleas do this. |
This commit only exposed existing bug in Argument Clinic. The same bug should be exposed for other methods that takes no keyword arguments converted to Argument Clinic. |
The PR LGTM. Thank you for your contribution SylvainDe! |
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: