Number of expected arguments in string methods TypeError messages are incorrect bug 1763 #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the problem :
The initial problem was that the number of args in the TypeError message was wrong.
Ex :
While searching to solve this problem, I realized the issue extended to every methods coming from Python. (append for list, clear for dict, split for string for exemple...)
Solution for this problem :
To create these error messages, the minargs and the maxargs of the original function are set in the info of the function.
When the TypeError is called, it uses minargs and maxargs stored in the info to build the message but their values are wrong because in their original description they take one more argument (self).
In order to have the right number to appear in the error message, we need to reduce the minargs and the maxargs by 1 at the creation of the function.
I made a simple test file to test some of the case that were wrong but the list of methods that were affected is too big (We need to complete with the test that are missing or find a better way to realize the test).
There are some builtins that still have wrong error message but the source of the problem is somewhere else (because even the number of arguments given is wrong).