[Python-checkins] python/dist/src/Tools/compiler dumppyc.py, 1.2, 1.3

jhylton@users.sourceforge.net jhylton at users.sourceforge.net
Thu Oct 20 21:59:28 CEST 2005


Update of /cvsroot/python/python/dist/src/Tools/compiler
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2121/Tools/compiler

Modified Files:
	dumppyc.py 
Log Message:
Merge ast-branch to head

This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests. 



Index: dumppyc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/dumppyc.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dumppyc.py	17 Sep 2001 18:08:20 -0000	1.2
+++ dumppyc.py	20 Oct 2005 19:59:25 -0000	1.3
@@ -28,7 +28,7 @@
         if type(obj) == types.CodeType:
             walk(obj, match)
 
-def main(filename, codename=None):
+def load(filename, codename=None):
     co = loadCode(filename)
     walk(co, codename)
 
@@ -39,6 +39,9 @@
     else:
         filename = sys.argv[1]
         codename = None
-    if filename.endswith('.py') and os.path.exists(filename+"c"):
-        filename += "c"
-    main(filename, codename)
+    if filename.endswith('.py'):
+        buf = open(filename).read()
+        co = compile(buf, filename, "exec")
+        walk(co)
+    else:   
+        load(filename, codename)



More information about the Python-checkins mailing list