This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Assigning to Ellipsis should be the same as assigning to __debug__
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, pablogsal, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-05-31 15:04 by aroberge, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26477 merged serhiy.storchaka, 2021-06-01 10:43
PR 26478 merged pablogsal, 2021-06-01 11:13
Messages (9)
msg394808 - (view) Author: Andre Roberge (aroberge) * Date: 2021-05-31 15:04
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
msg394824 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-31 20:27
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.
msg394825 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-31 20:31
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).
msg394826 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-31 20:31
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 '='?
msg394827 - (view) Author: Andre Roberge (aroberge) * Date: 2021-05-31 20:58
>
> I think that the suggestion to explicitly refer to '...' instead of the
name Ellipsis would be preferable.

Aside: I had not realized that this was done at a different stage for
__debug__ and Ellipsis ("Ignorance is bliss"...) and do realize that this
is a rare corner case that a beginner would almost never encountered.
(I'm just trying my best to prevent any kind of confusion in my own
program, and probably overestimate the potential for confusion here for
cPython users).
msg394829 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-05-31 22:15
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
msg394831 - (view) Author: Andre Roberge (aroberge) * Date: 2021-05-31 22:38
Up to your best judgment Pablo - and thanks for your ongoing work on improving error messages.
msg394853 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-06-01 11:07
New changeset 39dd141a4ba68bbb38fd00a65cdcff711acdafb5 by Serhiy Storchaka in branch 'main':
bpo-44273: Improve syntax error message for assigning to "..." (GH-26477)
https://github.com/python/cpython/commit/39dd141a4ba68bbb38fd00a65cdcff711acdafb5
msg395049 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-06-03 21:22
New changeset 3283bf4519139cf62ba04a76930f84ca1e7da910 by Pablo Galindo in branch '3.10':
[3.10] bpo-44273: Improve syntax error message for assigning to "..." (GH-26477) (GH-26478)
https://github.com/python/cpython/commit/3283bf4519139cf62ba04a76930f84ca1e7da910
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88439
2021-06-03 21:22:37pablogsalsetmessages: + msg395049
2021-06-01 11:14:23pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-06-01 11:13:17pablogsalsetpull_requests: + pull_request25073
2021-06-01 11:07:32pablogsalsetmessages: + msg394853
2021-06-01 10:43:36serhiy.storchakasetkeywords: + patch
nosy: + serhiy.storchaka

pull_requests: + pull_request25072
stage: patch review
2021-06-01 10:43:16serhiy.storchakalinkissue44278 superseder
2021-05-31 22:38:13arobergesetmessages: + msg394831
2021-05-31 22:15:02pablogsalsetmessages: + msg394829
2021-05-31 20:58:32arobergesetmessages: + msg394827
2021-05-31 20:31:44pablogsalsetmessages: + msg394826
2021-05-31 20:31:11pablogsalsetmessages: + msg394825
2021-05-31 20:27:55pablogsalsetmessages: + msg394824
2021-05-31 18:43:10BTaskayasetnosy: + pablogsal
2021-05-31 15:04:05arobergecreate