From 1c917072ca2895a196de7f397d4e96bcc577e13d Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 15 Oct 2001 15:44:05 +0000 Subject: Very subtle syntax change: in a list comprehension, the testlist in "for in may no longer be a single test followed by a comma. This solves SF bug #431886. Note that if the testlist contains more than one test, a trailing comma is still allowed, for maximum backward compatibility; but this example is not: [(x, y) for x in range(10), for y in range(10)] ^ The fix involved creating a new nonterminal 'testlist_safe' whose definition doesn't allow the trailing comma if there's only one test: testlist_safe: test [(',' test)+ [',']] --- Python/compile.c | 1 + 1 file changed, 1 insertion(+) (limited to 'Python/compile.c') diff --git a/Python/compile.c b/Python/compile.c index dae2a3eeb8..51209166cd 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3710,6 +3710,7 @@ com_node(struct compiling *c, node *n) /* Expression nodes */ case testlist: + case testlist_safe: com_list(c, n, 0); break; case test: -- cgit v1.2.1