Skip to content

Commit de12b79

Browse files
committed
allow test node after ** in calls (closes python#24176)
1 parent 8de32d9 commit de12b79

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

Grammar/Grammar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ arglist: argument (',' argument)* [',']
136136
# that precede iterable unpackings are blocked; etc.
137137
argument: ( test [comp_for] |
138138
test '=' test |
139-
'**' expr |
139+
'**' test |
140140
star_expr )
141141

142142
comp_iter: comp_for | comp_if

Lib/test/test_grammar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def d01(a=1): pass
206206
d01(1)
207207
d01(*(1,))
208208
d01(**{'a':2})
209+
d01(**{'a':2} or {})
209210
def d11(a, b=1): pass
210211
d11(1)
211212
d11(1, 2)

Modules/parsermodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@ validate_argument(node *tree)
28712871

28722872
if (res) {
28732873
if (TYPE(CHILD(tree, 0)) == DOUBLESTAR) {
2874-
res = validate_expr(CHILD(tree, 1));
2874+
res = validate_test(CHILD(tree, 1));
28752875
}
28762876
else if (nch == 1) {
28772877
res = validate_test_or_star_expr(CHILD(tree, 0));

Python/graminit.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,24 +1748,20 @@ static arc arcs_78_0[3] = {
17481748
};
17491749
static arc arcs_78_1[3] = {
17501750
{164, 3},
1751-
{31, 4},
1751+
{31, 2},
17521752
{0, 1},
17531753
};
17541754
static arc arcs_78_2[1] = {
1755-
{107, 3},
1755+
{26, 3},
17561756
};
17571757
static arc arcs_78_3[1] = {
17581758
{0, 3},
17591759
};
1760-
static arc arcs_78_4[1] = {
1761-
{26, 3},
1762-
};
1763-
static state states_78[5] = {
1760+
static state states_78[4] = {
17641761
{3, arcs_78_0},
17651762
{3, arcs_78_1},
17661763
{1, arcs_78_2},
17671764
{1, arcs_78_3},
1768-
{1, arcs_78_4},
17691765
};
17701766
static arc arcs_79_0[2] = {
17711767
{164, 1},
@@ -2021,7 +2017,7 @@ static dfa dfas[85] = {
20212017
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
20222018
{333, "arglist", 0, 3, states_77,
20232019
"\000\040\200\000\006\000\000\000\000\000\004\000\000\000\010\001\000\140\110\224\017\000"},
2024-
{334, "argument", 0, 5, states_78,
2020+
{334, "argument", 0, 4, states_78,
20252021
"\000\040\200\000\006\000\000\000\000\000\004\000\000\000\010\001\000\140\110\224\017\000"},
20262022
{335, "comp_iter", 0, 2, states_79,
20272023
"\000\000\000\000\000\000\000\000\000\000\000\000\021\000\000\000\000\000\000\000\000\000"},

0 commit comments

Comments
 (0)