bpo-32012: Disallow trailing comma after genexpr without parenthesis.… · python/cpython@9165f77 (original) (raw)

Original file line number Diff line number Diff line change
@@ -125,17 +125,32 @@
125 125
126 126 From ast_for_call():
127 127
128 ->>> def f(it, *varargs):
128 +>>> def f(it, *varargs, **kwargs):
129 129 ... return list(it)
130 130 >>> L = range(10)
131 131 >>> f(x for x in L)
132 132 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
133 133 >>> f(x for x in L, 1)
134 134 Traceback (most recent call last):
135 -SyntaxError: Generator expression must be parenthesized if not sole argument
135 +SyntaxError: Generator expression must be parenthesized
136 +>>> f(x for x in L, y=1)
137 +Traceback (most recent call last):
138 +SyntaxError: Generator expression must be parenthesized
139 +>>> f(x for x in L, *[])
140 +Traceback (most recent call last):
141 +SyntaxError: Generator expression must be parenthesized
142 +>>> f(x for x in L, **{})
143 +Traceback (most recent call last):
144 +SyntaxError: Generator expression must be parenthesized
145 +>>> f(L, x for x in L)
146 +Traceback (most recent call last):
147 +SyntaxError: Generator expression must be parenthesized
136 148 >>> f(x for x in L, y for y in L)
137 149 Traceback (most recent call last):
138 -SyntaxError: Generator expression must be parenthesized if not sole argument
150 +SyntaxError: Generator expression must be parenthesized
151 +>>> f(x for x in L,)
152 +Traceback (most recent call last):
153 +SyntaxError: Generator expression must be parenthesized
139 154 >>> f((x for x in L), 1)
140 155 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
141 156