Author mark_t_russell
Recipients
Date 2004-07-28.17:37:47
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=1017234

I've added an updated version of the patch, with the
following changes:

     - Applied against CVS head (as of 2004-07-28)
     - Non-standard C removed (see Guido's comment)
     - Newline before the def is now mandatory
     - Grammer for decorator expressions more restricted
     - tokenize.py and test_tokenize updated to handle @ tokens
     - Lib/compiler/transformer.py minimally updated

Still to do:

     - Complete work on Lib/compiler (i.e. get it to the
point where it
       produces a correct .pyc for code with decorators).
     - Write docs
     - Work through all the steps in PEP 306
     - Add more regression tests to test_decorator

I can put in some time on this in the next few days if this
patch seems likely
to be applied.

The grammar is now:

     decorator: '@' dotted_name [ '(' [arglist] ')' ]
     decorators: decorator ([NEWLINE] decorator)* NEWLINE
     funcdef: [decorators] 'def' NAME parameters ':' suite

This allows

     @foo @bar
     def f(): pass

but not:

     @foo @bar def f(): paqss

Issues:

    - Someone should take a look at the "case decorator:"
code in
      symtable_node() in compile.c.  All the tests pass, but
this
      seems a fragile bit of code to be changing

    - Lib/compiler needs some more work - at present
decorators are
      ignored there.  I'll do some more work on this when I
get time
      (probably this weekend).

    - As noted in the comments here, the build system does
not cope
      automatically with grammar changes.  The steps I used
to apply
      the patch are:

	   cd .../dist/src
           patch -p0 < /path/to/patch-file
	   ./configure
	   make
	   chmod +w Lib/symbol.py Lib/token.py
	   ./python Lib/symbol.py
	   ./python Lib/token.py
	   make clean
	   make
	   make test >& make-test.out

       I'm sure this sequence is non-optimal, but it works
for me, and
       all the tests pass on my Linux system afterwards.	   
History
Date User Action Args
2007-08-23 15:38:16adminlinkissue979728 messages
2007-08-23 15:38:16admincreate