]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport: SF bug #1167751: fix incorrect code being for generator expressions.
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 23 Oct 2005 00:44:03 +0000 (00:44 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 23 Oct 2005 00:44:03 +0000 (00:44 +0000)
Grammar/Grammar
Lib/test/test_genexps.py
Misc/NEWS
Python/graminit.c

index 9e4dad8078f40ecebd25f6c13eeaed971e2aaf8a..b99f8adb97fc0783ee48c7abc00c3b1aa9a7f493 100644 (file)
@@ -102,7 +102,7 @@ dictmaker: test ':' test (',' test ':' test)* [',']
 classdef: 'class' NAME ['(' testlist ')'] ':' suite
 
 arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test)
-argument: [test '='] test [gen_for] # Really [keyword '='] test
+argument: test [gen_for] | test '=' test ['(' gen_for ')'] # Really [keyword '='] test
 
 list_iter: list_for | list_if
 list_for: 'for' exprlist 'in' testlist_safe [list_iter]
index 04694f8e2e7ac6907c39569d8f1d89e529740fbf..5cd12bc230c6e51e17fea826d40632df6ff83eeb 100644 (file)
@@ -82,6 +82,18 @@ Verify that parenthesis are required in a statement
        ...
     SyntaxError: invalid syntax
 
+Verify that parenthesis are required when used as a keyword argument value
+
+    >>> dict(a = i for i in xrange(10))
+    Traceback (most recent call last):
+       ...
+    SyntaxError: invalid syntax
+
+Verify that parenthesis are required when used as a keyword argument value
+
+    >>> dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
+    {'a': <generator object at ...>}
+
 Verify early binding for the outermost for-expression
 
     >>> x=10
index 84ee619a0971311f8beca8ac2aca8bc48736bbb8..ab43a0ca9031378ae49b21aaf2b865945f49c524 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.4.3c1?
 Core and builtins
 -----------------
 
+- SF bug #1167751: fix incorrect code being for generator expressions.
+  The following code now raises a SyntaxError:  foo(a = i for i in range(10))
+
 - SF Bug #976608: fix SystemError when mtime of an imported file is -1.
 
 - SF Bug #887946: fix segfault when redirecting stdin from a directory.
index c4fe66148bf6bd5ccabfb8836c9e065aaccd57fb..c37bdc0da79fc5330488d664c208e83965b619e6 100644 (file)
@@ -1496,26 +1496,34 @@ static arc arcs_69_0[1] = {
        {26, 1},
 };
 static arc arcs_69_1[3] = {
-       {25, 2},
-       {147, 3},
+       {147, 2},
+       {25, 3},
        {0, 1},
 };
 static arc arcs_69_2[1] = {
-       {26, 4},
+       {0, 2},
 };
 static arc arcs_69_3[1] = {
-       {0, 3},
+       {26, 4},
 };
 static arc arcs_69_4[2] = {
-       {147, 3},
+       {13, 5},
        {0, 4},
 };
-static state states_69[5] = {
+static arc arcs_69_5[1] = {
+       {147, 6},
+};
+static arc arcs_69_6[1] = {
+       {15, 2},
+};
+static state states_69[7] = {
        {1, arcs_69_0},
        {3, arcs_69_1},
        {1, arcs_69_2},
        {1, arcs_69_3},
        {2, arcs_69_4},
+       {1, arcs_69_5},
+       {1, arcs_69_6},
 };
 static arc arcs_70_0[2] = {
        {146, 1},
@@ -1791,7 +1799,7 @@ static dfa dfas[78] = {
         "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"},
        {324, "arglist", 0, 8, states_68,
         "\000\040\010\060\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
-       {325, "argument", 0, 5, states_69,
+       {325, "argument", 0, 7, states_69,
         "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
        {326, "list_iter", 0, 2, states_70,
         "\000\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000"},