[New-bugs-announce] [issue45807] Strange SyntaxError message / suggestions for "@x = 123"

Pierre Quentel report at bugs.python.org
Mon Nov 15 09:41:01 EST 2021


New submission from Pierre Quentel <pierre.quentel at gmail.com>:

In CPython 3.10 :

Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> @x = 123
  File "<stdin>", line 1
    @x = 123
     ^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

but both suggestions lead to a SyntaxError :

>>> @x == 123
...
  File "<stdin>", line 2

    ^
SyntaxError: invalid syntax
>>> @x := 123
...
  File "<stdin>", line 2

    ^
SyntaxError: invalid syntax
>>>


Maybe an error message such as "cannot assign to decorator" would be more appropriate ?

----------
components: Parser
messages: 406351
nosy: lys.nikolaou, pablogsal, quentel
priority: normal
severity: normal
status: open
title: Strange SyntaxError message / suggestions for "@x = 123"
type: enhancement
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45807>
_______________________________________


More information about the New-bugs-announce mailing list