[Python-checkins] cpython: allow test node after ** in calls (closes #24176)

benjamin.peterson python-checkins at python.org
Sat May 16 15:45:03 CEST 2015


https://hg.python.org/cpython/rev/38b2307372bf
changeset:   96086:38b2307372bf
parent:      96084:ce07e646b76e
user:        Benjamin Peterson <benjamin at python.org>
date:        Sat May 16 09:44:45 2015 -0400
summary:
  allow test node after ** in calls (closes #24176)

files:
  Grammar/Grammar          |   2 +-
  Lib/test/test_grammar.py |   1 +
  Modules/parsermodule.c   |   2 +-
  Python/graminit.c        |  12 ++++--------
  4 files changed, 7 insertions(+), 10 deletions(-)


diff --git a/Grammar/Grammar b/Grammar/Grammar
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -136,7 +136,7 @@
 # that precede iterable unpackings are blocked; etc.
 argument: ( test [comp_for] |
             test '=' test |
-            '**' expr |
+            '**' test |
             star_expr )
 
 comp_iter: comp_for | comp_if
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -206,6 +206,7 @@
         d01(1)
         d01(*(1,))
         d01(**{'a':2})
+        d01(**{'a':2} or {})
         def d11(a, b=1): pass
         d11(1)
         d11(1, 2)
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -2871,7 +2871,7 @@
 
     if (res) {
         if (TYPE(CHILD(tree, 0)) == DOUBLESTAR) {
-            res = validate_expr(CHILD(tree, 1));
+            res = validate_test(CHILD(tree, 1));
         }
         else if (nch == 1) {
             res = validate_test_or_star_expr(CHILD(tree, 0));
diff --git a/Python/graminit.c b/Python/graminit.c
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -1748,24 +1748,20 @@
 };
 static arc arcs_78_1[3] = {
     {164, 3},
-    {31, 4},
+    {31, 2},
     {0, 1},
 };
 static arc arcs_78_2[1] = {
-    {107, 3},
+    {26, 3},
 };
 static arc arcs_78_3[1] = {
     {0, 3},
 };
-static arc arcs_78_4[1] = {
-    {26, 3},
-};
-static state states_78[5] = {
+static state states_78[4] = {
     {3, arcs_78_0},
     {3, arcs_78_1},
     {1, arcs_78_2},
     {1, arcs_78_3},
-    {1, arcs_78_4},
 };
 static arc arcs_79_0[2] = {
     {164, 1},
@@ -2021,7 +2017,7 @@
      "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
     {333, "arglist", 0, 3, states_77,
      "\000\040\200\000\006\000\000\000\000\000\004\000\000\000\010\001\000\140\110\224\017\000"},
-    {334, "argument", 0, 5, states_78,
+    {334, "argument", 0, 4, states_78,
      "\000\040\200\000\006\000\000\000\000\000\004\000\000\000\010\001\000\140\110\224\017\000"},
     {335, "comp_iter", 0, 2, states_79,
      "\000\000\000\000\000\000\000\000\000\000\000\000\021\000\000\000\000\000\000\000\000\000"},

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list