[pypy-svn] r56358 - in pypy/dist/pypy/module/recparser: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Jul 7 19:32:48 CEST 2008


Author: cfbolz
Date: Mon Jul  7 19:32:45 2008
New Revision: 56358

Modified:
   pypy/dist/pypy/module/recparser/pyparser.py
   pypy/dist/pypy/module/recparser/test/test_parser.py
Log:
Wrap a parser error properly.


Modified: pypy/dist/pypy/module/recparser/pyparser.py
==============================================================================
--- pypy/dist/pypy/module/recparser/pyparser.py	(original)
+++ pypy/dist/pypy/module/recparser/pyparser.py	Mon Jul  7 19:32:45 2008
@@ -222,8 +222,12 @@
 
 
 def source2ast(space, source):
+    from pypy.interpreter.pyparser.error import SyntaxError
     compiler = get_ast_compiler(space)
-    return space.wrap(compiler.source2ast(source, 'exec'))
+    try:
+        return space.wrap(compiler.source2ast(source, 'exec'))
+    except SyntaxError, e:
+        raise OperationError(space.w_SyntaxError, e.wrap_info(space, "<parser-module>"))
 source2ast.unwrap_spec = [ObjSpace, str]
 
 

Modified: pypy/dist/pypy/module/recparser/test/test_parser.py
==============================================================================
--- pypy/dist/pypy/module/recparser/test/test_parser.py	(original)
+++ pypy/dist/pypy/module/recparser/test/test_parser.py	Mon Jul  7 19:32:45 2008
@@ -28,3 +28,7 @@
         import parser
         raises(parser.ParserError, parser.sequence2st, ())
 
+    def test_source2ast_bug1(self):
+        import parser
+        raises(SyntaxError, parser.source2ast, "\xDE\xDA")
+



More information about the Pypy-commit mailing list