-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-44640: Improve punctuation in isinstance() error message #27144
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
Conversation
Does this need news? IMO it's a very minor change, but it involves frequently-used builtins. |
The word "union" is actually an exception to the "a/an" rule. Here is more detail: https://english.stackexchange.com/questions/266309/why-is-union-an-exception-to-the-a-an-rule |
OK :) English isn't my first language. |
@wyz23x2 It's all good! English is very fickle and the fact that "union" is an exception to the a/an rule is a pretty obscure one. To be clear, I don't think that the punctuation removal is necessary either; the original message is a grammatically correct full sentence. In its current state, you left behind the first comma, and removed all the following punctuation, which is not correct. Unfortunately, as far as I can tell, there are no changes needed here; but feel free to let me know if you think I'm missing something. |
I agree it's somehow a "micro" change and maybe not needed.
I just thought it's strange because all others aren't really full sentences since they have no periods: >>> import math, sys
>>> int([])
Traceback (most recent call last):
...
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
>>> math.sqrt(-1)
Traceback (most recent call last):
...
ValueError: math domain error
>>> [3.14][sys.maxsize+100]
Traceback (most recent call last):
...
IndexError: cannot fit 'int' into an index-sized integer
>>> import mathh
Traceback (most recent call last):
...
ModuleNotFoundError: No module named 'mathh' etc. |
But then again, those other messages are simpler single-statement messages. Since this message is a three-part list, maybe the punctuation in this case provides some needed clarity? In any case, you have to think about those chaotic individuals who have written code which asserts against the content of the error message here. Python is big enough that it probably has happened, and this change will break that person's (albeit questionable) code. |
It's unlikely for there to be much code reliant on that. Union support is 3.10 onwards only, and 3.10.0 isn't out yet (only the betas). So I don't think any code is going to break. |
While, the |
P.S. I'm sure that it was noted before, but actually any object that implements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll leave it up to the core dev merging this to decide whether we should backport this to 3.10 or not (personally, I don't think it will hurt, but this doesn't look like a something we usually backport either so I'm not too sure).
Without offering an opinion on whether this change is desirable, just offering that you could say "Add serial comma" rather than "Fix punctuation". Yes, a period is added also, but if this is change is worth merging, it would likely only be for the serial comma. |
Ping. |
GH-28436 is a backport of this pull request to the 3.10 branch. |
…rror messages (pythonGH-27144) Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit f481338) Co-authored-by: wyz23x2 <[email protected]>
…rror messages (GH-27144) (GH-28436) Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit f481338) Co-authored-by: wyz23x2 <[email protected]> Co-authored-by: wyz23x2 <[email protected]>
…rror messages (pythonGH-27144) (pythonGH-28436) Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit f481338) Co-authored-by: wyz23x2 <[email protected]> Co-authored-by: wyz23x2 <[email protected]>
|
…rror messages (pythonGH-27144) Co-authored-by: Łukasz Langa <[email protected]>
Unify the punctuation marks of
isinstance()
andissubclass()
error messages.https://bugs.python.org/issue44640