Issue39200
Created on 2020-01-03 14:27 by jferard, last changed 2020-01-16 00:48 by corona10. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17813 | merged | pablogsal, 2020-01-03 14:50 | |
| PR 17814 | merged | corona10, 2020-01-03 16:17 | |
| PR 17940 | closed | miss-islington, 2020-01-10 16:45 | |
| PR 17941 | closed | miss-islington, 2020-01-10 16:45 | |
| PR 17942 | closed | miss-islington, 2020-01-10 16:45 | |
| PR 17943 | closed | miss-islington, 2020-01-10 16:45 | |
| Messages (11) | |||
|---|---|---|---|
| msg359236 - (view) | Author: Julien Férard (jferard) * | Date: 2020-01-03 14:27 | |
When passing no argument to `range`, the error message states that (exactly) one argument is expected.
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:
TypeError: range expected at least 1 argument, got 0
(See for instance:
>>> eval()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: eval expected at least 1 argument, got 0
)
|
|||
| msg359243 - (view) | Author: Dong-hee Na (corona10) * | Date: 2020-01-03 16:36 | |
I noticed that min/max builtin function also has the same problem. For example, PyPy raise TypeError as TypeError: max() expects at least one argument. PR-17814 is an update patch for this. I suggest changing the title to be "Fix inaccurate TypeError messages when calling with insufficient arguments" |
|||
| msg359363 - (view) | Author: Pablo Galindo Salgado (pablogsal) * | Date: 2020-01-05 17:30 | |
New changeset 4b66fa6ce9c37e70b55af220d0e07368319de803 by Pablo Galindo in branch 'master': bpo-39200: Correct the error message for range() empty constructor (GH-17813) https://github.com/python/cpython/commit/4b66fa6ce9c37e70b55af220d0e07368319de803 |
|||
| msg359423 - (view) | Author: Dong-hee Na (corona10) * | Date: 2020-01-06 13:21 | |
@pablogsal PR 17813 is merged. If you don't mind, can we review PR 17814 that will be applied or not? |
|||
| msg359736 - (view) | Author: STINNER Victor (vstinner) * | Date: 2020-01-10 16:31 | |
New changeset abdc634f337ce4943cd7d13587936837aac2ecc9 by Victor Stinner (Dong-hee Na) in branch 'master': bpo-39200: Correct the error message for min/max builtin function (GH-17814) https://github.com/python/cpython/commit/abdc634f337ce4943cd7d13587936837aac2ecc9 |
|||
| msg359737 - (view) | Author: STINNER Victor (vstinner) * | Date: 2020-01-10 16:32 | |
Dong-hee, Pablo: Should we backport the two fixes to 3.7 and 3.8 branches? IMHO yes, we should backport. |
|||
| msg359738 - (view) | Author: Dong-hee Na (corona10) * | Date: 2020-01-10 16:40 | |
Victor: Changes are only correcting the message. I am +1 on backporting :) |
|||
| msg359739 - (view) | Author: STINNER Victor (vstinner) * | Date: 2020-01-10 16:47 | |
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). |
|||
| msg359776 - (view) | Author: Dong-hee Na (corona10) * | Date: 2020-01-11 04:18 | |
CPython or stdlib: There is no code depends on the error message of range and min/max. 3rd party: IMHO, if somebody relies on the error message, not error type, I think that the code pattern is bad usage And as I mentioned on msg359243, other python compatible compilers/interpreters already don't follow the same error message as CPython. If the issue had been caused by this issue, it would have already been reported. But it doesn't seem to be. So my conclusion is that it will not be a problem. :) |
|||
| msg360081 - (view) | Author: STINNER Victor (vstinner) * | Date: 2020-01-15 21:52 | |
> 3rd party: IMHO, if somebody relies on the error message, not error type, I think that the code pattern is bad usage 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. |
|||
| msg360091 - (view) | Author: Dong-hee Na (corona10) * | Date: 2020-01-16 00:48 | |
Thanks for the opinion. Sounds reasonable! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2020-01-16 00:48:35 | corona10 | set | messages: + msg360091 |
| 2020-01-15 21:52:16 | vstinner | set | status: open -> closed versions: - Python 3.7, Python 3.8 messages: + msg360081 resolution: fixed |
| 2020-01-11 04:18:48 | corona10 | set | messages: + msg359776 |
| 2020-01-10 16:47:16 | vstinner | set | messages: + msg359739 |
| 2020-01-10 16:45:46 | miss-islington | set | pull_requests: + pull_request17350 |
| 2020-01-10 16:45:39 | miss-islington | set | pull_requests: + pull_request17349 |
| 2020-01-10 16:45:17 | miss-islington | set | pull_requests: + pull_request17348 |
| 2020-01-10 16:45:09 | miss-islington | set | pull_requests: + pull_request17347 |
| 2020-01-10 16:40:51 | corona10 | set | messages: + msg359738 |
| 2020-01-10 16:32:41 | vstinner | set | messages: + msg359737 |
| 2020-01-10 16:31:51 | vstinner | set | nosy:
+ vstinner messages: + msg359736 |
| 2020-01-06 13:21:27 | corona10 | set | messages: + msg359423 |
| 2020-01-05 17:30:57 | pablogsal | set | messages: + msg359363 |
| 2020-01-03 17:28:53 | pablogsal | set | title: Inaccurate TypeError message for `range` without argument -> Fix inaccurate TypeError messages when calling with insufficient arguments |
| 2020-01-03 16:45:48 | corona10 | set | versions: - Python 3.5, Python 3.6 |
| 2020-01-03 16:36:00 | corona10 | set | nosy:
+ pablogsal, corona10 messages:
+ msg359243 |
| 2020-01-03 16:35:08 | SilentGhost | set | versions: - Python 3.5, Python 3.6 |
| 2020-01-03 16:17:13 | corona10 | set | pull_requests: + pull_request17241 |
| 2020-01-03 14:50:29 | pablogsal | set | keywords:
+ patch stage: patch review pull_requests: + pull_request17240 |
| 2020-01-03 14:27:51 | jferard | create | |