[pypy-svn] r5076 - in pypy/trunk/src/pypy/module: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Jun 12 17:01:53 CEST 2004
Author: arigo
Date: Sat Jun 12 17:01:52 2004
New Revision: 5076
Modified:
pypy/trunk/src/pypy/module/__builtin__interp.py
pypy/trunk/src/pypy/module/test/test_builtin.py
Log:
Fixed the built-in compile() to catch SyntaxError (duh!).
Added tests.
Modified: pypy/trunk/src/pypy/module/__builtin__interp.py
==============================================================================
--- pypy/trunk/src/pypy/module/__builtin__interp.py (original)
+++ pypy/trunk/src/pypy/module/__builtin__interp.py Sat Jun 12 17:01:52 2004
@@ -209,6 +209,8 @@
# It would be nice to propagate all exceptions to app level,
# but here we only propagate the 'usual' ones, until we figure
# out how to do it generically.
+ except SyntaxError,e:
+ raise OperationError(space.w_SyntaxError,space.wrap(str(e)))
except ValueError,e:
raise OperationError(space.w_ValueError,space.wrap(str(e)))
except TypeError,e:
Modified: pypy/trunk/src/pypy/module/test/test_builtin.py
==============================================================================
--- pypy/trunk/src/pypy/module/test/test_builtin.py (original)
+++ pypy/trunk/src/pypy/module/test/test_builtin.py Sat Jun 12 17:01:52 2004
@@ -230,6 +230,14 @@
self.assertRaises(TypeError, hash, [])
self.assertRaises(TypeError, hash, {})
+ def test_compile(self):
+ co = compile('1+2', '?', 'eval')
+ self.assertEquals(eval(co), 3)
+ self.assertRaises(SyntaxError, compile, '-', '?', 'eval')
+ self.assertRaises(ValueError, compile, '"\\xt"', '?', 'eval')
+ self.assertRaises(ValueError, compile, '1+2', '?', 'maybenot')
+ self.assertRaises(TypeError, compile, '1+2', 12, 34)
+
class TestInternal(testit.IntTestCase):
More information about the Pypy-commit
mailing list