mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
(Merge 3.3) Issue #17223: array module: Fix a crasher when converting an array
containing invalid characters (outside range [U+0000; U+10ffff]) to Unicode: repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.
This commit is contained in:
commit
25c3053a4f
3 changed files with 12 additions and 0 deletions
|
@ -1069,6 +1069,12 @@ class UnicodeTest(StringTest, unittest.TestCase):
|
||||||
|
|
||||||
self.assertRaises(TypeError, a.fromunicode)
|
self.assertRaises(TypeError, a.fromunicode)
|
||||||
|
|
||||||
|
def test_issue17223(self):
|
||||||
|
# this used to crash
|
||||||
|
a = array.array('u', b'\xff' * 4)
|
||||||
|
self.assertRaises(ValueError, a.tounicode)
|
||||||
|
self.assertRaises(ValueError, str, a)
|
||||||
|
|
||||||
class NumberTest(BaseTest):
|
class NumberTest(BaseTest):
|
||||||
|
|
||||||
def test_extslice(self):
|
def test_extslice(self):
|
||||||
|
|
|
@ -10,6 +10,10 @@ What's New in Python 3.4.0 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #17223: array module: Fix a crasher when converting an array containing
|
||||||
|
invalid characters (outside range [U+0000; U+10ffff]) to Unicode:
|
||||||
|
repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.
|
||||||
|
|
||||||
- Issue #17223: Fix PyUnicode_FromUnicode() for string of 1 character outside
|
- Issue #17223: Fix PyUnicode_FromUnicode() for string of 1 character outside
|
||||||
the range U+0000-U+10ffff.
|
the range U+0000-U+10ffff.
|
||||||
|
|
||||||
|
|
|
@ -2177,6 +2177,8 @@ array_repr(arrayobject *a)
|
||||||
} else {
|
} else {
|
||||||
v = array_tolist(a, NULL);
|
v = array_tolist(a, NULL);
|
||||||
}
|
}
|
||||||
|
if (v == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v);
|
s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v);
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue