[issue44838] SyntaxError: New message "expected 'else' after 'if' expression" wrongly shown

Pablo Galindo Salgado report at bugs.python.org
Thu Aug 5 12:16:31 EDT 2021


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

This is a tricky one because the tokenizer doesn't see the enclosed parentheses because is actually closed (the second print has two 
')' parentheses).

This is tricky indeed because the parser is parsing the ( after the print as a group, not as a call, and indentation doesn't matter in the group.

We can indeed revert the PR but I'm afraid that you can use this pattern to actually trigger a bunch of other custom error messages where they should not.

----------

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


More information about the Python-bugs-list mailing list