Issue found while trying to write tests for https://bugs.python.org/issue30592 . Issue related to http://bugs.python.org/issue30534 . The following code: [].index(x=2) should raise the following error: TypeError: index() takes no keyword arguments but currently raises: TypeError: index() takes at least 1 argument (0 given) 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 , 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).
Thanks Serhiy Storchaka for the tip! I am currently investigating how the argument clinic works. I have used git bisect to find when the issue got introduced. commit fdd42c481edba4261f861fc1dfe24bbd79b5a17abpo-20185: Convert list object implementation to Argument Clinic. (#542)
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.