diff Python/compile.c @ 20432:56141b86a7f2 legacy-trunk

Very subtle syntax change: in a list comprehension, the testlist in "for <var> in <testlist> 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)+ [',']]
author Guido van Rossum <guido@python.org>
date Mon, 15 Oct 2001 15:44:05 +0000
parents 3faabf54b8b8
children 149a65fa427c
line wrap: on
line diff
--- a/Python/compile.c	Mon Oct 15 14:34:42 2001 +0000
+++ b/Python/compile.c	Mon Oct 15 15:44:05 2001 +0000
@@ -3710,6 +3710,7 @@
 	/* Expression nodes */
 	
 	case testlist:
+	case testlist_safe:
 		com_list(c, n, 0);
 		break;
 	case test: