Author: Armin Rigo <[email protected]>
Branch:
Changeset: r96550:d8a9df1bc3eb
Date: 2019-04-29 09:55 +0200
http://bitbucket.org/pypy/pypy/changeset/d8a9df1bc3eb/
Log: Test and fix
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
@@ -1059,7 +1059,7 @@
# some invalid utf8-encoded string which makes things
# potentially explode left and right.
try:
- item = rutf8.unichr_as_utf8(code)
+ item = rutf8.unichr_as_utf8(code, allow_surrogates=True)
except rutf8.OutOfRange:
raise oefmt(space.w_ValueError,
"cannot operate on this array('u') because it contains"
diff --git a/pypy/module/array/test/test_array.py
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -871,6 +871,10 @@
assert a.tounicode() == input_unicode
raises(ValueError, b.tounicode) # doesn't work
+ def test_unicode_surrogate(self):
+ a = self.array('u', u'\ud800')
+ assert a[0] == u'\ud800'
+
def test_weakref(self):
import weakref
a = self.array('c', 'Hi!')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit