bpo-32023: Disallow genexprs without parenthesis in class definitions. by serhiy-storchaka · Pull Request #4400 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Doc/whatsnew/3.7.rst
4 changes: 4 additions & 0 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
SyntaxError: Generator expression must be parenthesized
>>> f((x for x in L), 1)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> class C(x for x in L):
... pass
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> def g(*args, **kwargs):
... print(args, sorted(kwargs.items()))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SyntaxError is now correctly raised when a generator expression without
parenthesis is used instead of an inheritance list in a class definition.
The duplication of the parentheses can be omitted only on calls.
15 changes: 10 additions & 5 deletions Python/ast.c