]> granicus.if.org Git - python/commitdiff
Issue #25969: Update the lib2to3 grammar to handle the unpacking
authorGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>
Sat, 10 Sep 2016 01:19:51 +0000 (18:19 -0700)
committerGregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) <greg@krypto.org>
Sat, 10 Sep 2016 01:19:51 +0000 (18:19 -0700)
generalizations added in 3.5.

1  2 
Lib/lib2to3/Grammar.txt
Lib/lib2to3/tests/test_fixers.py
Lib/lib2to3/tests/test_parser.py
Misc/NEWS

index dcdd02d6629f126a7a0abd076554dc2d4414ec2d,88f7884b5a55d9a4c8751d4e26d7af565050f4c6..2f02e6f07cca8ca21557c4d9dadcb1d153668d60
@@@ -144,13 -145,22 +146,22 @@@ dictsetmaker: ( ((test ':' test | '**' 
  
  classdef: 'class' NAME ['(' [arglist] ')'] ':' suite
  
- arglist: (argument ',')* (argument [',']
-                          |'*' test (',' argument)* [',' '**' test]
-                          |'**' test)
- argument: test [comp_for] | test '=' test  # Really [keyword '='] test
+ arglist: argument (',' argument)* [',']
+ # "test '=' test" is really "keyword '=' test", but we have no such token.
+ # These need to be in a single rule to avoid grammar that is ambiguous
+ # to our LL(1) parser. Even though 'test' includes '*expr' in star_expr,
+ # we explicitly match '*' here, too, to give it proper precedence.
+ # Illegal combinations and orderings are blocked in ast.c:
+ # multiple (test comp_for) arguements are blocked; keyword unpackings
+ # that precede iterable unpackings are blocked; etc.
+ argument: ( test [comp_for] |
+             test '=' test |
+           '**' expr |
+           star_expr )
  
  comp_iter: comp_for | comp_if
 -comp_for: 'for' exprlist 'in' testlist_safe [comp_iter]
 +comp_for: [ASYNC] 'for' exprlist 'in' testlist_safe [comp_iter]
  comp_if: 'if' old_test [comp_iter]
  
  testlist1: test (',' test)*
Simple merge
Simple merge
diff --cc Misc/NEWS
Simple merge