New submission from Saiyang Gou <[email protected]>:
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
----------
messages: 390369
nosy: gousaiyang
priority: normal
severity: normal
status: open
title: lambda expression no longer valid at comp_if in Python 3.9
type: behavior
versions: Python 3.10, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43755>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com