[pypy-svn] r17404 - in pypy/dist/pypy: interpreter interpreter/test translator/goal
ac at codespeak.net
ac at codespeak.net
Fri Sep 9 14:52:25 CEST 2005
Author: ac
Date: Fri Sep 9 14:52:25 2005
New Revision: 17404
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
pypy/dist/pypy/interpreter/test/test_compiler.py
pypy/dist/pypy/translator/goal/targetcompiler.py
Log:
Test compilation of some unicode literals.
Make targetcompiler fully use the ast-compiler.
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Fri Sep 9 14:52:25 2005
@@ -121,6 +121,12 @@
space.wrap(e.offset),
space.wrap(e.text)])])
raise OperationError(space.w_SyntaxError, w_synerr)
+ except UnicodeDecodeError, e:
+ # TODO use a custom UnicodeError
+ raise OperationError(space.w_UnicodeDecodeError, space.newtuple([
+ space.wrap(e.encoding), space.wrap(e.object),
+ space.wrap(e.start),
+ space.wrap(e.end), space.wrap(e.reason)]))
except ValueError, e:
raise OperationError(space.w_ValueError, space.wrap(str(e)))
except TypeError, e:
@@ -403,7 +409,6 @@
return self.compile_parse_result(ast_tree, filename, mode, flags)
def compile_parse_result(self, ast_tree, filename, mode, flags):
- """NOT_RPYTHON"""
# __________
# XXX this uses the non-annotatable astcompiler at interp-level
from pypy.interpreter import astcompiler
@@ -429,17 +434,19 @@
space.wrap(e.offset),
space.wrap(e.text)])])
raise OperationError(space.w_SyntaxError, w_synerr)
- except UnicodeDecodeError, e:
- # TODO use a custom UnicodeError
- raise OperationError(space.w_UnicodeDecodeError, space.newtuple([
- space.wrap(e.encoding), space.wrap(e.object), space.wrap(e.start),
- space.wrap(e.end), space.wrap(e.reason)]))
+## except UnicodeDecodeError, e:
+## # TODO use a custom UnicodeError
+## import traceback
+## traceback.print_exc()
+## raise OperationError(space.w_UnicodeDecodeError, space.newtuple([
+## space.wrap(e.encoding), space.wrap(e.object), space.wrap(e.start),
+## space.wrap(e.end), space.wrap(e.reason)]))
except ValueError,e:
- if e.__class__ != ValueError:
- extra_msg = "(Really go %s)" % e.__class__.__name__
- else:
- extra_msg = ""
- raise OperationError(space.w_ValueError,space.wrap(str(e)+extra_msg))
+ #if e.__class__ != ValueError:
+ # extra_msg = "(Really go %s)" % e.__class__.__name__
+ #else:
+ # extra_msg = ""
+ raise OperationError(space.w_ValueError,space.wrap(str(e)))
except TypeError,e:
raise
raise OperationError(space.w_TypeError,space.wrap(str(e)))
Modified: pypy/dist/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/dist/pypy/interpreter/test/test_compiler.py Fri Sep 9 14:52:25 2005
@@ -10,6 +10,11 @@
def setup_method(self, method):
self.compiler = self.space.createcompiler()
+ def eval_string(self, string):
+ space = self.space
+ code = self.compiler.compile(string, '<>', 'eval', 0)
+ return code.exec_code(space, space.newdict([]), space.newdict([]))
+
def test_compile(self):
code = self.compiler.compile('6*7', '<hello>', 'eval', 0)
assert isinstance(code, PyCode)
@@ -150,6 +155,21 @@
assert not space.eq_w(w_const, space.wrap("b"))
assert not space.eq_w(w_const, space.wrap("c"))
+ def test_unicodeliterals(self):
+ e = py.test.raises(OperationError, self.eval_string, "u'\\Ufffffffe'")
+ ex = e.value
+ ex.normalize_exception(self.space)
+ assert ex.match(self.space, self.space.w_UnicodeError)
+
+ e = py.test.raises(OperationError, self.eval_string, "u'\\Uffffffff'")
+ ex = e.value
+ ex.normalize_exception(self.space)
+ assert ex.match(self.space, self.space.w_UnicodeError)
+
+ e = py.test.raises(OperationError, self.eval_string, "u'\\U%08x'" % 0x110000)
+ ex = e.value
+ ex.normalize_exception(self.space)
+ assert ex.match(self.space, self.space.w_UnicodeError)
class TestECCompiler(BaseTestCompiler):
def setup_method(self, method):
Modified: pypy/dist/pypy/translator/goal/targetcompiler.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetcompiler.py (original)
+++ pypy/dist/pypy/translator/goal/targetcompiler.py Fri Sep 9 14:52:25 2005
@@ -30,7 +30,7 @@
# for the poor translator already
# XXX why can't I enable this? crashes the annotator!
space = StdObjSpace(nofaking=True,
- compiler="_stable",
+ compiler="ast",
translating=True,
#usemodules=['marhsal', '_sre'],
geninterp=geninterp)
More information about the Pypy-commit
mailing list