this test is only valid when sizeof(wchar) == Py_UNICODE_SIZE

This commit is contained in:
Benjamin Peterson 2010-08-25 17:02:22 +00:00
parent ef6ff662c9
commit b35f646796
1 changed files with 5 additions and 3 deletions

View File

@ -67,15 +67,17 @@ def test_cstrings(self):
self.assertTrue(c_char_p.from_param(a) is a) self.assertTrue(c_char_p.from_param(a) is a)
def test_cw_strings(self): def test_cw_strings(self):
from ctypes import byref from ctypes import byref, sizeof
try: try:
from ctypes import c_wchar_p from ctypes import c_wchar, c_wchar_p
except ImportError: except ImportError:
## print "(No c_wchar_p)" ## print "(No c_wchar_p)"
return return
s = "123" s = "123"
if sys.platform == "win32": if sys.platform == "win32":
self.assertTrue(c_wchar_p.from_param(s)._obj is s) unisize = 8 if sys.maxunicode == 1114111 else 4
if unisize == sizeof(c_wchar):
self.assertIs(c_wchar_p.from_param(s)._obj, s)
self.assertRaises(TypeError, c_wchar_p.from_param, 42) self.assertRaises(TypeError, c_wchar_p.from_param, 42)
# new in 0.9.1: convert (decode) ascii to unicode # new in 0.9.1: convert (decode) ascii to unicode