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
Assigning to Ellipsis should be the same as assigning to __debug__ #88439
Comments
Consider the following in Python 3.10 >>> ... = 1
File "<stdin>", line 1
... = 1
^^^
SyntaxError: cannot assign to Ellipsis here. Maybe you meant '==' instead of '='?
>>> __debug__ = 1
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__ In prior Python versions, assignments to Ellisis written as ... were treated the same as assignment to __debug__. I believe that the old message was a better choice. The error message about assigning to Ellipsis (...) is made even more confusing since Ellipsis (the name) can be assigned to a different value. >>> ... == Ellipsis
True
>>> Ellipsis = 1
>>> ... == Ellipsis
False
>>> ...
Ellipsis |
Hummmm, I sort of agree, but I need to weigh how complex is going to be to special-case. I really don't want to start adding many different paths for the different built-ins in different situations. |
Also, another problem is that "cannot assign to __debug__" is actually a compiler error, while "cannot assign to Ellipsis here. Maybe you meant '==' instead of '='?" is a parser error. This is because "__debug__" is tokenized as NAME while '...' is tokenized as ELLIPSIS (it's own token). |
What we can do is to replace: SyntaxError: cannot assign to Ellipsis here. Maybe you meant '==' instead of '='? for SyntaxError: cannot assign to '...' here. Maybe you meant '==' instead of '='? |
Aside: I had not realized that this was done at a different stage for |
I suggest to just close it or otherwise changing the message to include "..." instead of "Ellipsis". Anything else is actually much more complex than it seems, unfortunately |
Up to your best judgment Pablo - and thanks for your ongoing work on improving error messages. |
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: