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
Fix inaccurate TypeError messages when calling with insufficient arguments #83381
Comments
When passing no argument to Actual: Python 3.9.0a0 (heads/master:d395209653, Jan 3 2020, 11:37:03)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> range()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: range expected 1 argument, got 0 Expected message:
(See for instance: >>> eval()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: eval expected at least 1 argument, got 0
) |
I noticed that min/max builtin function also has the same problem. For example, PyPy raise TypeError as PR-17814 is an update patch for this. I suggest changing the title to be "Fix inaccurate TypeError messages when calling with insufficient arguments" |
range
without argumentrange
without argument
@pablogsal |
Dong-hee, Pablo: Should we backport the two fixes to 3.7 and 3.8 branches? IMHO yes, we should backport. |
Victor: Changes are only correcting the message. |
Backport PRs are ready for 3.7 and 3.8. Question: is there a risk of breaking the backward compatibility if a project unit test rely on the exact error message? If yes, maybe it's better to reject the backports and close this issue (only change the error message in 3.9). |
CPython or stdlib: There is no code depends on the error message of range and min/max. And as I mentioned on msg359243, other python compatible compilers/interpreters already don't follow the same error message as CPython. So my conclusion is that it will not be a problem. :) |
I don't think that we can be pedantic on how projects should be tested. IMHO it's too risky. I rejected backports. The risk of regression in a *minor* release is just too high. Such "cleanup" change is better fitted for a new 3.x major release. |
Thanks for the opinion. |
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: