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 gousaiyang
Recipients gousaiyang
Date 2021-04-06.20:07:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617739645.22.0.813638332511.issue43755@roundup.psfhosted.org>
In-reply-to
Content
According to the documentation, a lambda expression at the `comp_if` position of a comprehension is allowed (can be parsed as `lambda_expr_nocond`). But this seems broken in Python 3.9 PEG parser. Example:

user@host:/$ python3.8
Python 3.8.9 (default, Apr  3 2021, 01:00:00)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> [x for x in range(10) if lambda: 1]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
user@host:/$ python3.9
Python 3.9.3 (default, Apr  3 2021, 00:51:37)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> [x for x in range(10) if lambda: 1]
  File "<stdin>", line 1
    [x for x in range(10) if lambda: 1]
                             ^
SyntaxError: invalid syntax
History
Date User Action Args
2021-04-06 20:07:25gousaiyangsetrecipients: + gousaiyang
2021-04-06 20:07:25gousaiyangsetmessageid: <1617739645.22.0.813638332511.issue43755@roundup.psfhosted.org>
2021-04-06 20:07:25gousaiyanglinkissue43755 messages
2021-04-06 20:07:25gousaiyangcreate