cpython: 66e9d0185b0f (original) (raw)
Mercurial > cpython
changeset 82407:66e9d0185b0f 3.3
Issue #17223: Fix test_array on Windows (16-bit wchar_t/Py_UNICODE) [#17223]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 26 Feb 2013 22:52:11 +0100 |
parents | 17673a8c7083 |
children | 5aaf6bc1d502 83ae10bf608c |
files | Lib/test/test_array.py |
diffstat | 1 files changed, 18 insertions(+), 11 deletions(-)[+] [-] Lib/test/test_array.py 29 |
line wrap: on
line diff
--- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -24,6 +24,17 @@ try: except struct.error: have_long_long = False +try:
+ + class ArraySubclass(array.array): pass @@ -1040,16 +1051,6 @@ class UnicodeTest(StringTest, unittest.T minitemsize = 2 def test_unicode(self):
try:[](#l1.25)
import ctypes[](#l1.26)
sizeof_wchar = ctypes.sizeof(ctypes.c_wchar)[](#l1.27)
except ImportError:[](#l1.28)
import sys[](#l1.29)
if sys.platform == 'win32':[](#l1.30)
sizeof_wchar = 2[](#l1.31)
else:[](#l1.32)
sizeof_wchar = 4[](#l1.33)
- self.assertRaises(TypeError, array.array, 'b', 'foo') a = array.array('u', '\xa0\xc2\u1234') @@ -1071,7 +1072,13 @@ class UnicodeTest(StringTest, unittest.T def test_issue17223(self): # this used to crash
a = array.array('u', b'\xff' * 4)[](#l1.42)
if sizeof_wchar == 4:[](#l1.43)
# U+FFFFFFFF is an invalid code point in Unicode 6.0[](#l1.44)
invalid_str = b'\xff\xff\xff\xff'[](#l1.45)
else:[](#l1.46)
# invalid UTF-16 surrogate pair[](#l1.47)
invalid_str = b'\xff\xdf\x61\x00'[](#l1.48)
a = array.array('u', invalid_str)[](#l1.49) self.assertRaises(ValueError, a.tounicode)[](#l1.50) self.assertRaises(ValueError, str, a)[](#l1.51)