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.

Author aroberge
Recipients aroberge, lys.nikolaou, pablogsal
Date 2021-05-19.18:38:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621449485.2.0.442417390344.issue44180@roundup.psfhosted.org>
In-reply-to
Content
When an equal sign is used instead of a colon in creating a dict literal, depending on the context, either the "bad token" is misidentified OR the would-be helpful error message is incorrect in this particular case.

1) Example of bad token.
Previously, the = sign was identified correctly:

>>> ages = {'Alice'=22, 'Bob'=23}
  File "<stdin>", line 1
    ages = {'Alice'=22, 'Bob'=23}
                   ^
SyntaxError: invalid syntax

With Python 3.10.0b1, the comma is identified as the bad token:

>>> ages = {'Alice'=22, 'Bob'=23}
  File "<stdin>", line 1
    ages = {'Alice'=22, 'Bob'=23}
                      ^
SyntaxError: invalid syntax


2) Example of incorrect error message

Previously, we got the traditional and unhelpful "invalid syntax" but with the bad token identified correctly:

>>> ages = {'Alice'=22}
  File "<stdin>", line 1
    ages = {'Alice'=22}
                   ^
SyntaxError: invalid syntax

With Python 3.10.0b1, we get the following:

>>> ages = {'Alice'=22}
  File "<stdin>", line 1
    ages = {'Alice'=22}
            ^^^^^^^
SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?

I suspect that the ratio (== suggestion correct/ : suggestion correct) would be vanishingly small. ;-)
History
Date User Action Args
2021-05-19 18:38:05arobergesetrecipients: + aroberge, lys.nikolaou, pablogsal
2021-05-19 18:38:05arobergesetmessageid: <1621449485.2.0.442417390344.issue44180@roundup.psfhosted.org>
2021-05-19 18:38:05arobergelinkissue44180 messages
2021-05-19 18:38:05arobergecreate