[Patches] [ python-Patches-1013835 ] Implementation for PEP 318 using syntax J2

SourceForge.net noreply at sourceforge.net
Wed Aug 25 22:17:25 CEST 2004


Patches item #1013835, was opened at 2004-08-22 16:39
Message generated for change (Comment added) made by ms_
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1013835&group_id=5470

Category: Parser/Compiler
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael (ms_)
Assigned to: Nobody/Anonymous (nobody)
Summary: Implementation for PEP 318 using syntax J2

Initial Comment:
This patch implements decorator syntax J2 from 
http://www.python.org/moin/PythonDecorators 
 
Example: 
class Foo: 
   decorate: 
      staticmethod deprecated memoize 
      author("Joe Bloggs") 
   def foo(bar): 
      pass 
 
Key changes: 
   * Grammar/Grammar updated 
   * Python/compile.c updated. 
   * Test suite, docs and Lib updated. (test suite passes on my 
linux box) 
 
Specific changes: 
   * Grammar/Grammar changed to recognise J2 syntax 
   * Python/compile.c changed to support J2 
   * Removed "@" from Lib/tokenize.py as Special 
   * Removed "AT" from joe Include/token.h as a token 
   * Removed "AT" from Parser/tokenizer.c 
   * Doc/lib/libfuncs.tex - Changed examples from @ format 
     to decorate: format 
   * Doc/ref/ref7.tex  
      - changed Function Definitions production rules to match 
        the change in syntax. 
      - Changed example to use the change in syntax. 
   * Lib/compiler/transformer.py - Modified to handle the new 
syntax 
   * Lib/test/test_parser.py - Changed tests for old syntax to 
check new form 
   * Lib/test/tokenize_tests.txt - changed @staticmethod to J2 
format 
   * Lib/test/output/test_tokenize - Changed to match the 
changed test file 
   * Modules/parsermodule.c - Changed to support new 
Grammar 
   * Lib/test/pyclbr_input.py - Changed from @ syntax to 
decorate: syntax 
   * Lib/test/test_decorators.py - changed all "decorate" 
functions to 
     decorate_ and all @ usages to "decorate:" syntax. 
      
Files checked, but not changed: 
   * Doc/lib/asttable.tex - Can't see any necessary changes 
   * Lib/compiler/pycodegen.py - Can't see any necessary 
changes 
   * Lib/compiler/symbols.py - Can't see any necessary 
changes 
   * Tools/compiler/ast.txt - Can't see any necessary changes 
   * Tools/compiler/astgen.py - Can't see any necessary 
changes 
   * Tools/compiler/regrtest.py - No changes 
NB: 
   * I can't see whether ast.py should/should not be changed 
and 
     if it should, *how* it should be changed, as a result I've left 
     well alone. 
 
Issues: 
   * Keyword clash with test suite is bad - suggest change to 
"using" 
     to limit clash with existing user code as far as possible. 
     I intend to follow this up with a replacement with a 
     changed keyword and if possible shortened/simplified 
     version. 
   * Patch is against the vanilla 2.4a2 download from 
python.org, does 
     this need changing to being a patch against the current 
CVS head? 
     (I suspect the answer to this is "yes") 
   * The following tests are skipped on my machine: 
       test_aepack test_al test_applesingle test_bsddb185 
test_bsddb3 
       test_cd test_cl test_codecmaps_cn test_codecmaps_hk 
       test_codecmaps_jp test_codecmaps_kr 
test_codecmaps_tw test_curses 
       test_gdbm test_gl test_imgfile test_largefile 
test_linuxaudiodev 
       test_macfs test_macostools test_nis test_normalization 
       test_ossaudiodev test_pep277 test_plistlib 
test_scriptpackages 
       test_socket_ssl test_socketserver test_sunaudiodev 
test_tcl 
       test_timeout test_urllibnet test_winreg test_winsound 
      
     As a result I don't know for certain these aren't affected by 
the 
     change. I'm checking them by hand at present. 
 

----------------------------------------------------------------------

>Comment By: Michael (ms_)
Date: 2004-08-25 21:17

Message:
Logged In: YES 
user_id=994316

Updated patch against anonymous CVS.  
Covers the same files as before, with the addition of changes to  
test_inspect.py, and inspect.py. inspect.py was updated to handle  
the paired decorate/def blocks. Specifically this required changes  
to getblock such that if getblock is called on a decorated function  
that both blocks are returned rather than just the function or just  
the decorator suite. This is to preserve the same behaviour as the 
current inspect behaviour. 
 
Also: 
* changed keyword to "using" 
* Eliminated the single clash in the library that uses "using" as a 
variable. (webbrowser.py has a function "get" that has "using" as a 
single named parameter. AFAICT no google findable source file 
uses this parameter) 
* implemented the short form: 
using: trace 
def someFunction(someThing): doStuff(someThing) 
* Decorators are single decorator per line - as per current CVS, 
which means the short form only takes 1 decorator. 
 
All tests except test_distutils pass. Since this appear to fail in Anon 
CVS without this patch that failure looks unrelated. 
 
Remaining issues(?): 
* It's been suggested that this should be activated by a __future__ 
declaration. I'm currently looking at how to do this. 
* Extra docs on short form would probably be a good idea. (Docs 
are already updated otherwise) 
 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1013835&group_id=5470


More information about the Patches mailing list