IronLanguages / IronLanguages/ironpython3
Incorrect error message when calling function with invalid signature
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
Description
The message of the error raised by functions called with an invalid signature has changed between Python 2 and 3.
Python 3 reports the names of the missing arguments, for example, whereas Python 2 just reports the number of expected arguments and the number given (including for self in member functions).
IronPython does not match the behaviour of Python 2 in all cases.
Steps to Reproduce
Case 1 - too few arguments
>>> round()
Expected behavior: round() missing required argument 'number' (pos 1)
Actual behavior: round() takes at least 1 argument (0 given)
This behaviour does not match 🛑
Case 2 - too many arguments
>>> round(1,2,3)
Expected behavior: round() takes at most 2 arguments (3 given)
Actual behavior: round() takes at most 2 arguments (3 given)
This behaviour matches 🆗
Case 3 - incorrect argument name
>>> round(n=1)
Expected behavior: round() missing required argument 'number' (pos 1)
Actual behavior: round() got an unexpected keyword argument 'n'
This behaviour does not match 🛑
Case 4 - positional argument follows keyword argument
>>> round(number=1, 2)
Expected behavior: positional argument follows keyword argument
Actual behavior: non-keyword arg after keyword arg'
This behaviour does not match 🛑
Case 5 - incorrect argument name after correct name
>>> round(number=1, n=1)
Expected behavior: 'n' is an invalid keyword argument for round()
Actual behavior: round() got an unexpected keyword argument 'n'
This behaviour does not match 🛑
Notes
The cases given above are almost certainly not exhaustive.
IMO the value in fixing these messages earlier rather than later is the danger in them being fixed on a case by case basis and then needing to be unfixed later on.
Versions
Found in: https://github.com/IronLanguages/ironpython3/commit/11ecefaac7f2cd17dad7aac9102843ee5c225a91
I tested on Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] as there are no 3.4 binaries available on Python.org and I'm too lazy to build the executable myself.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by reproducing the five reported invalid-signature calls and compare IronPython's messages with the stated Python 2 expectations; done means the listed cases and additional signature-error cases consistently produce the intended wording.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100