New submission from kai zhu <[EMAIL PROTECTED]>: this patch touches only Python/ceval.c.
1. the only existing thing it modifies is PyEval_EvalFrameEx (adds 8 extra cases for the new 3.0 opcodes, doesn't mess w/ any of the existing ones, or anything else as a matter of fact) 2. that, plus it defines (the new opcodes) #define SET_ADD 17 #define STORE_MAP 54 #define STORE_LOCALS 69 #define LOAD_BUILD_CLASS 34 #define MAKE_BYTES 35 #define POP_EXCEPT 36 #define UNPACK_EX 94 #define BUILD_SET 109 and some backported vars & helper functions only 2 contiguous areas of ceval.c is patched (1. & 2. - areas are delimited by the comments '// py3k') this simple patch seems sufficient in theory to allow the interpreter to natively execute most of 3.0's language syntax (nonlocal, print, extended unpacking... have been tested to work) *the one exception being pep3102 - keyword-only arguments i wrote 2 small scripts which gives an interactive function 'compile_py3k' similar to __builtin__.compile except it works only for 3.0 syntax. it doesn't actually compile, but rather cheats by querying it to a python 3.0 server via pipe io. here is an interactive demonstration of my script: example demonstrating pep3132 extended unpacking syntax: a,b,*c = 1,2,3,4 Python 2.5.2 (r252:60911, Jun 27 2008, 21:19:51) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import py3to2 py3to2 server restarting with io: (4, 5) py3to2 server: Python 3.0b1 (r30b1:64395, Jun 24 2008, 21:53:55) py3to2 server: [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 py3to2 server: Type "help", "copyright", "credits" or "license" for more information. py3to2 server: >>> src = "a,b,*c = 1,2,3,4" >>> codeobject = py3to2.compile_py3k(src,"","exec") 1 0 LOAD_CONST 5 ((1, 2, 3, 4)) 3 UNPACK_EX_py3k 2 6 STORE_NAME 0 (a) 9 STORE_NAME 1 (b) 12 STORE_NAME 2 (c) 15 LOAD_CONST 4 (None) 18 RETURN_VALUE >>> exec(codeobject); print "a=%s, b=%s, c=%s"%(a,b,c) a=1, b=2, c=[3, 4] >>> u can go c http://pypi.python.org/pypi?name=py3to2&version=20080628&:action=display for more info anyway, i think it would b a great boost for python 3.0 (which i think is very cool) if developers can test/develop it under the robust 2.5 environment. this patch plus some scripts could go a long way in making that happen ---------- assignee: collinwinter components: 2to3 (2.x to 3.0 conversion tool) files: ceval.c messages: 68873 nosy: collinwinter, kaizhu severity: normal status: open title: backport python 3.0 language functionality to python 2.5 by adding 8 opcodes to ceval.c type: feature request versions: Python 2.5 Added file: http://bugs.python.org/file10758/ceval.c _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3225> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com