]> granicus.if.org Git - python/commitdiff
Fix com_arglist() and update grammar fragment.
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 19 Apr 2002 22:56:37 +0000 (22:56 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 19 Apr 2002 22:56:37 +0000 (22:56 +0000)
SF bug #522264 reported by Evelyn Mitchell.

The code included a comment about "STAR STAR" which was translated
into the code as the bogus attribute token.STARSTAR.  This name never
caused an attribute error because it was never retrieved.  The code
was based on an old version of the grammar that specified kwargs as
two tokens ('*' '*').  I checked as far back as 2.1 and didn't find
this production.

The fix is simple, because token.DOUBLESTAR is the only token
allowed.  Also update the grammar fragment in com_arglist().

XXX I'll bet lots of other grammar fragments in comments are out of
date, probably in this module and in compile.c.

Lib/compiler/transformer.py

index b05d3a83217b3cd3b5f1275d37f8dd01863bb203..32a4160c253b78995ce5c4334216881169c65f18 100644 (file)
@@ -746,9 +746,8 @@ class Transformer:
 
     def com_arglist(self, nodelist):
         # varargslist:
-        #   (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
-        #  | fpdef ['=' test] (',' fpdef ['=' test])* [',']
-        #  | ('**'|'*' '*') NAME)
+        #     (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME)
+        #   | fpdef ['=' test] (',' fpdef ['=' test])* [',']
         # fpdef: NAME | '(' fplist ')'
         # fplist: fpdef (',' fpdef)* [',']
         names = []
@@ -767,12 +766,10 @@ class Transformer:
                         i = i + 3
 
                 if i < len(nodelist):
-                    # should be DOUBLESTAR or STAR STAR
+                    # should be DOUBLESTAR
                     t = nodelist[i][0]
                     if t == token.DOUBLESTAR:
                         node = nodelist[i+1]
-                    elif t == token.STARSTAR:
-                        node = nodelist[i+2]
                     else:
                         raise ValueError, "unexpected token: %s" % t
                     names.append(node[1])