Message393964
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. ;-) |
|
Date |
User |
Action |
Args |
2021-05-19 18:38:05 | aroberge | set | recipients:
+ aroberge, lys.nikolaou, pablogsal |
2021-05-19 18:38:05 | aroberge | set | messageid: <1621449485.2.0.442417390344.issue44180@roundup.psfhosted.org> |
2021-05-19 18:38:05 | aroberge | link | issue44180 messages |
2021-05-19 18:38:05 | aroberge | create | |
|