Issue 30600: Error message incorrect when index is called with keyword argument ("[].index(x=2)") (original) (raw)

Created on 2017-06-08 12:25 by SylvainDe, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
git_bisect_bpo30600.txt SylvainDe,2017-06-09 12:27
Pull Requests
URL Status Linked Edit
PR 2051 merged SylvainDe,2017-06-09 23:24
Messages (8)
msg295427 - (view) Author: SylvainDe (SylvainDe) * Date: 2017-06-08 12:25
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)
msg295432 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-08 12:37
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).
msg295434 - (view) Author: SylvainDe (SylvainDe) * Date: 2017-06-08 12:39
Can I give this a try or is anyone working on this already ?
msg295437 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-08 12:45
Yes, pleas do this.
msg295519 - (view) Author: SylvainDe (SylvainDe) * Date: 2017-06-09 12:27
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 fdd42c481edba4261f861fc1dfe24bbd79b5a17a bpo-20185: Convert list object implementation to Argument Clinic. (#542)
msg295523 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-09 12:38
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.
msg295610 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-10 04:51
New changeset 7445381c606faf20e253da42656db478a4349f8e by Serhiy Storchaka (Sylvain) in branch 'master': bpo-30600: Fix error messages (condition order in Argument Clinic) (#2051) https://github.com/python/cpython/commit/7445381c606faf20e253da42656db478a4349f8e
msg295611 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-10 04:57
The PR LGTM. Thank you for your contribution SylvainDe!
History
Date User Action Args
2022-04-11 14:58:47 admin set github: 74785
2017-06-10 04:57:41 serhiy.storchaka set status: open -> closedversions: - Python 3.6messages: + resolution: fixedstage: needs patch -> resolved
2017-06-10 04:51:50 serhiy.storchaka set messages: +
2017-06-09 23:24:33 SylvainDe set pull_requests: + <pull%5Frequest2113>
2017-06-09 12:45:07 Jim Fasarakis-Hilliard set nosy: + Jim Fasarakis-Hilliard
2017-06-09 12:38:07 serhiy.storchaka set messages: +
2017-06-09 12:27:09 SylvainDe set files: + git_bisect_bpo30600.txtmessages: +
2017-06-08 12:45:47 serhiy.storchaka set messages: +
2017-06-08 12:39:12 SylvainDe set messages: +
2017-06-08 12:37:59 serhiy.storchaka set components: + Argument Clinicversions: + Python 3.6keywords: + easynosy: + serhiy.storchaka, larrymessages: + stage: needs patch
2017-06-08 12:25:37 SylvainDe create