[Patches] [ python-Patches-1013835 ] Implementation for PEP 318
using syntax J2
SourceForge.net
noreply at sourceforge.net
Wed Sep 1 11:32:30 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: Closed
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-09-01 10:32
Message:
Logged In: YES
user_id=994316
From:
http://mail.python.org/pipermail/python-dev/2004-September/048518.html
Guido wrote:
"I've read the J2 proposal up and down several times, pondered all
the issues, and slept on it for a night, and I still don't like it
enough to accept it."
I'm closing this patch as a result, I hope that's the right thing to
do.
----------------------------------------------------------------------
Comment By: Michael (ms_)
Date: 2004-08-26 17:19
Message:
Logged In: YES
user_id=994316
The updated patch is against anon CVS as of 26 Aug 2004, 17:00.
This patch leaves the keyword unchanged as "using". All tests
pass on my machine (with "make testall").
The key change is that the keyword - and hence decorators must
now be actively switched on using a "from __future__ import
decorators" statement. The code using this is heavily based on the
same approach that "from __future__ import generators" took --
indeed reusing as much as possible.
I suspect that it might be wise to have more tests regarding
decorators, and the docs might need a small amount of work, any
feedback welcome on this point.
----------------------------------------------------------------------
Comment By: Michael (ms_)
Date: 2004-08-26 17:13
Message:
Logged In: YES
user_id=994316
----------------------------------------------------------------------
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