[issue34013] Inconsistent SyntaxError for print

Pablo Galindo Salgado report at bugs.python.org
Sat Jul 31 19:12:37 EDT 2021


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

Is not about the eagerness, the problem is that it matches *first*, the parser never gets to the indentation error in the second phase.

For example, with:

print(3) $ 34

❯ ./python bug.py
  File "/home/pablogsal/github/python/main/bug.py", line 1
    print(3) $ 34
    ^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

The problem is that is matching the (3) as print + a number between parentheses. We just need to disallow to continue matching on the right
if it finds a '('.

----------

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


More information about the Python-bugs-list mailing list