[pypy-svn] r79082 - in pypy/branch/fast-forward/pypy/interpreter: astcompiler test
afa at codespeak.net
afa at codespeak.net
Mon Nov 15 00:46:02 CET 2010
Author: afa
Date: Mon Nov 15 00:46:01 2010
New Revision: 79082
Modified:
pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
pypy/branch/fast-forward/pypy/interpreter/test/test_compiler.py
Log:
UnicodeError in literal should be turned into a SyntaxError
Modified: pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py Mon Nov 15 00:46:01 2010
@@ -1087,9 +1087,15 @@
encoding = self.compile_info.encoding
flags = self.compile_info.flags
unicode_literals = flags & consts.CO_FUTURE_UNICODE_LITERALS
- sub_strings_w = [parsestring.parsestr(space, encoding, s.value,
- unicode_literals)
- for s in atom_node.children]
+ try:
+ sub_strings_w = [parsestring.parsestr(space, encoding, s.value,
+ unicode_literals)
+ for s in atom_node.children]
+ except error.OperationError, e:
+ if not e.match(space, space.w_UnicodeError):
+ raise
+ # UnicodeError in literal: turn into SyntaxError
+ self.error(e.errorstr(space), atom_node)
# This implements implicit string concatenation.
if len(sub_strings_w) > 1:
w_sub_strings = space.newlist(sub_strings_w)
Modified: pypy/branch/fast-forward/pypy/interpreter/test/test_compiler.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/test/test_compiler.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/test/test_compiler.py Mon Nov 15 00:46:01 2010
@@ -206,25 +206,21 @@
assert not space.eq_w(w_const, space.wrap("b"))
assert not space.eq_w(w_const, space.wrap("c"))
- _unicode_error_kind = "w_UnicodeError"
-
def test_unicodeliterals(self):
- w_error = getattr(self.space, self._unicode_error_kind)
-
e = py.test.raises(OperationError, self.eval_string, "u'\\Ufffffffe'")
ex = e.value
ex.normalize_exception(self.space)
- assert ex.match(self.space, w_error)
+ assert ex.match(self.space, self.space.w_SyntaxError)
e = py.test.raises(OperationError, self.eval_string, "u'\\Uffffffff'")
ex = e.value
ex.normalize_exception(self.space)
- assert ex.match(self.space, w_error)
+ assert ex.match(self.space, self.space.w_SyntaxError)
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, w_error)
+ assert ex.match(self.space, self.space.w_SyntaxError)
def test_unicode_docstring(self):
space = self.space
More information about the Pypy-commit
mailing list