Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b35f646

Browse files
committed
this test is only valid when sizeof(wchar) == Py_UNICODE_SIZE
1 parent ef6ff66 commit b35f646

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Lib/ctypes/test/test_parameters.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,17 @@ def test_cstrings(self):
6767
self.assertTrue(c_char_p.from_param(a) is a)
6868

6969
def test_cw_strings(self):
70-
from ctypes import byref
70+
from ctypes import byref, sizeof
7171
try:
72-
from ctypes import c_wchar_p
72+
from ctypes import c_wchar, c_wchar_p
7373
except ImportError:
7474
## print "(No c_wchar_p)"
7575
return
7676
s = "123"
7777
if sys.platform == "win32":
78-
self.assertTrue(c_wchar_p.from_param(s)._obj is s)
78+
unisize = 8 if sys.maxunicode == 1114111 else 4
79+
if unisize == sizeof(c_wchar):
80+
self.assertIs(c_wchar_p.from_param(s)._obj, s)
7981
self.assertRaises(TypeError, c_wchar_p.from_param, 42)
8082

8183
# new in 0.9.1: convert (decode) ascii to unicode

0 commit comments

Comments
 (0)