[pypy-svn] r17265 - pypy/dist/pypy/interpreter/stablecompiler

adim at codespeak.net adim at codespeak.net
Tue Sep 6 11:52:03 CEST 2005


Author: adim
Date: Tue Sep  6 11:52:01 2005
New Revision: 17265

Modified:
   pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py
   pypy/dist/pypy/interpreter/stablecompiler/transformer.py
Log:
added a filename default argument to parse() to match Transformer's new API



Modified: pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py	(original)
+++ pypy/dist/pypy/interpreter/stablecompiler/pycodegen.py	Tue Sep  6 11:52:01 2005
@@ -75,7 +75,7 @@
         self.code = None
 
     def _get_tree(self):
-        tree = parse(self.source, self.mode)
+        tree = parse(self.source, self.mode, self.filename)
         misc.set_filename(self.filename, tree)
         syntax.check(tree)
         return tree

Modified: pypy/dist/pypy/interpreter/stablecompiler/transformer.py
==============================================================================
--- pypy/dist/pypy/interpreter/stablecompiler/transformer.py	(original)
+++ pypy/dist/pypy/interpreter/stablecompiler/transformer.py	Tue Sep  6 11:52:01 2005
@@ -54,11 +54,12 @@
     f.close()
     return parse(src)
 
-def parse(buf, mode="exec"):
+# added a filename keyword argument to improve SyntaxErrors' messages
+def parse(buf, mode="exec", filename=''):
     if mode == "exec" or mode == "single":
-        return Transformer().parsesuite(buf)
+        return Transformer(filename).parsesuite(buf)
     elif mode == "eval":
-        return Transformer().parseexpr(buf)
+        return Transformer(filename).parseexpr(buf)
     else:
         raise ValueError("compile() arg 3 must be"
                          " 'exec' or 'eval' or 'single'")
@@ -109,7 +110,7 @@
         tree = parsefile(fileob | filename)
     """
 
-    def __init__(self, filename):
+    def __init__(self, filename=''):
         self._dispatch = {}
         self.filename = filename
         for value, name in symbol.sym_name.items():



More information about the Pypy-commit mailing list