[pypy-commit] pypy default: test and fix
arigo
pypy.commits at gmail.com
Tue Jan 24 09:41:59 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r89736:ad54ed3f27d2
Date: 2017-01-24 15:31 +0100
http://bitbucket.org/pypy/pypy/changeset/ad54ed3f27d2/
Log: test and fix
diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1104,8 +1104,9 @@
if not e.match(space, space.w_UnicodeError):
raise
# UnicodeError in literal: turn into SyntaxError
- self.error(e.errorstr(space), atom_node)
- sub_strings_w = [] # please annotator
+ e.normalize_exception(space)
+ errmsg = space.str_w(space.str(e.get_w_value(space)))
+ raise self.error('(unicode error) %s' % errmsg, atom_node)
# This implements implicit string concatenation.
if len(sub_strings_w) > 1:
w_sub_strings = space.newlist(sub_strings_w)
diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -1240,3 +1240,9 @@
if1, if2 = comps[0].ifs
assert isinstance(if1, ast.Name)
assert isinstance(if2, ast.Name)
+
+ def test_decode_error_in_string_literal(self):
+ input = "u'\\x'"
+ exc = py.test.raises(SyntaxError, self.get_ast, input).value
+ assert exc.msg == ("(unicode error) 'unicodeescape' codec can't decode"
+ " bytes in position 0-1: truncated \\xXX escape")
More information about the pypy-commit
mailing list