summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-07-13 11:19:35 (GMT)
committerThomas Heller <theller@ctypes.org>2007-07-13 11:19:35 (GMT)
commite5095e187ba80a5265d44807c7371440f903dc31 (patch)
tree54443135dd55f5bf7a2cc39c370542030ed2ea6c /Lib
parent745f5e2de709722e1586df597af59477cb3f6980 (diff)
downloadcpython-e5095e187ba80a5265d44807c7371440f903dc31.zip
cpython-e5095e187ba80a5265d44807c7371440f903dc31.tar.gz
cpython-e5095e187ba80a5265d44807c7371440f903dc31.tar.bz2
Structure fields of type c_char array or c_wchar array accept bytes or
(unicode) string.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_bytes.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_bytes.py b/Lib/ctypes/test/test_bytes.py
index 25e017b..e6e047a 100644
--- a/Lib/ctypes/test/test_bytes.py
+++ b/Lib/ctypes/test/test_bytes.py
@@ -1,3 +1,4 @@
+"""Test where byte objects are accepted"""
import unittest
from ctypes import *
@@ -22,5 +23,19 @@ class BytesTest(unittest.TestCase):
c_wchar_p("foo bar")
c_wchar_p(b"foo bar")
+ def test_struct(self):
+ class X(Structure):
+ _fields_ = [("a", c_char * 3)]
+
+ X("abc")
+ X(b"abc")
+
+ def test_struct_W(self):
+ class X(Structure):
+ _fields_ = [("a", c_wchar * 3)]
+
+ X("abc")
+ X(b"abc")
+
if __name__ == '__main__':
unittest.main()