This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark_t_russell
Date 2004-07-28.17:37:47
SpamBayes Score
Marked as misclassified
Logged In: YES 

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
     - and test_tokenize updated to handle @ tokens
     - Lib/compiler/ 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


    - Someone should take a look at the "case decorator:"
code in
      symtable_node() in compile.c.  All the tests pass, but
      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
	   chmod +w Lib/ Lib/
	   ./python Lib/
	   ./python Lib/
	   make clean
	   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.	   
Date User Action Args
2007-08-23 15:38:16adminlinkissue979728 messages
2007-08-23 15:38:16admincreate