[Python-checkins] python/dist/src/Modules parsermodule.c,2.83,2.84

mwh at users.sourceforge.net mwh at users.sourceforge.net
Tue Aug 17 19:29:32 CEST 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1056/Modules

Modified Files:
	parsermodule.c 
Log Message:
This is Mark Russell's patch:

[ 1009560 ] Fix @decorator evaluation order

>From the description:

Changes in this patch:

- Change Grammar/Grammar to require
newlines between adjacent decorators.

- Fix order of evaluation of decorators
in the C (compile.c) and python
(Lib/compiler/pycodegen.py) compilers

- Add better order of evaluation check
to test_decorators.py (test_eval_order)

- Update the decorator documentation in
the reference manual (improve description
of evaluation order and update syntax
description)

and the comment:

Used Brett's evaluation order (see
http://mail.python.org/pipermail/python-dev/2004-August/047835.html)

(I'm checking this in for Anthony who was having problems getting SF to
talk to him)


Index: parsermodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v
retrieving revision 2.83
retrieving revision 2.84
diff -C2 -d -r2.83 -r2.84
*** parsermodule.c	2 Aug 2004 06:09:55 -0000	2.83
--- parsermodule.c	17 Aug 2004 17:29:15 -0000	2.84
***************
*** 2365,2369 ****
  
  /*  decorator:
!  *    '@' dotted_name [ '(' [arglist] ')' ]
   */
  static int
--- 2365,2369 ----
  
  /*  decorator:
!  *    '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
   */
  static int
***************
*** 2373,2393 ****
      int nch = NCH(tree);
      ok = (validate_ntype(tree, decorator) &&
! 	  (nch == 2 || nch == 4 || nch == 5) &&
  	  validate_at(CHILD(tree, 0)) &&
! 	  validate_dotted_name(CHILD(tree, 1)));
  
!     if (ok && nch != 2) {
! 	    ok = (validate_lparen(CHILD(tree, 2)) &&
! 		  validate_rparen(RCHILD(tree, -1)));
  
! 	    if (ok && nch == 5)
! 		ok = validate_arglist(CHILD(tree, 3));
      }
  
      return ok;
  }
!     
  /*  decorators:
!  *    decorator ([NEWLINE] decorator)* NEWLINE
   */
  static int
--- 2373,2394 ----
      int nch = NCH(tree);
      ok = (validate_ntype(tree, decorator) &&
! 	  (nch == 3 || nch == 5 || nch == 6) &&
  	  validate_at(CHILD(tree, 0)) &&
! 	  validate_dotted_name(CHILD(tree, 1)) &&
! 	  validate_newline(RCHILD(tree, -1)));
  
!     if (ok && nch != 3) {
! 	ok = (validate_lparen(CHILD(tree, 2)) &&
! 	      validate_rparen(RCHILD(tree, -2)));
  
! 	if (ok && nch == 6)
! 	    ok = validate_arglist(CHILD(tree, 3));
      }
  
      return ok;
  }
! 
  /*  decorators:
!  *    decorator+
   */
  static int
***************
*** 2396,2411 ****
      int i, nch, ok; 
      nch = NCH(tree);
!     ok = validate_ntype(tree, decorators) && nch >= 2;
  
!     i = 0;
!     while (ok && i < nch - 1) {
  	ok = validate_decorator(CHILD(tree, i));
- 	if (TYPE(CHILD(tree, i + 1)) == NEWLINE)
- 	    ++i;
- 	++i;
-     }
  
      return ok;
! }			       
  
  /*  funcdef:
--- 2397,2407 ----
      int i, nch, ok; 
      nch = NCH(tree);
!     ok = validate_ntype(tree, decorators) && nch >= 1;
  
!     for (i = 0; ok && i < nch; ++i)
  	ok = validate_decorator(CHILD(tree, i));
  
      return ok;
! }
  
  /*  funcdef:



More information about the Python-checkins mailing list