[Python-checkins] python/dist/src/Lib/compiler transformer.py,1.32,1.33

jhylton@sourceforge.net jhylton@sourceforge.net
Fri, 19 Apr 2002 15:56:40 -0700


Update of /cvsroot/python/python/dist/src/Lib/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv15229

Modified Files:
	transformer.py 
Log Message:
Fix com_arglist() and update grammar fragment.
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.


Index: transformer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** transformer.py	28 Feb 2002 17:48:48 -0000	1.32
--- transformer.py	19 Apr 2002 22:56:37 -0000	1.33
***************
*** 747,753 ****
      def com_arglist(self, nodelist):
          # varargslist:
!         #   (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
!         #  | fpdef ['=' test] (',' fpdef ['=' test])* [',']
!         #  | ('**'|'*' '*') NAME)
          # fpdef: NAME | '(' fplist ')'
          # fplist: fpdef (',' fpdef)* [',']
--- 747,752 ----
      def com_arglist(self, nodelist):
          # varargslist:
!         #     (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME)
!         #   | fpdef ['=' test] (',' fpdef ['=' test])* [',']
          # fpdef: NAME | '(' fplist ')'
          # fplist: fpdef (',' fpdef)* [',']
***************
*** 768,777 ****
  
                  if i < len(nodelist):
!                     # should be DOUBLESTAR or STAR STAR
                      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
--- 767,774 ----
  
                  if i < len(nodelist):
!                     # should be DOUBLESTAR
                      t = nodelist[i][0]
                      if t == token.DOUBLESTAR:
                          node = nodelist[i+1]
                      else:
                          raise ValueError, "unexpected token: %s" % t