[pypy-commit] pypy unicode-utf8: Raise ValueError when array item is invalid unicode
rlamy
pypy.commits at gmail.com
Mon Dec 11 21:44:41 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: unicode-utf8
Changeset: r93379:bdbea29862af
Date: 2017-12-12 02:44 +0000
http://bitbucket.org/pypy/pypy/changeset/bdbea29862af/
Log: Raise ValueError when array item is invalid unicode
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -1030,7 +1030,11 @@
return space.newbytes(item)
elif mytype.typecode == 'u':
code = r_uint(ord(item))
- return space.newutf8(rutf8.unichr_as_utf8(code), 1)
+ try:
+ return space.newutf8(rutf8.unichr_as_utf8(code), 1)
+ except ValueError:
+ raise oefmt(space.w_ValueError,
+ "character is not in range [U+0000; U+10ffff]")
assert 0, "unreachable"
# interface
More information about the pypy-commit
mailing list