diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-11 21:50:30 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-06-11 21:50:30 (GMT) |
commit | da0eca427aef6c58f3c134c0789f54d7b8fa4210 (patch) | |
tree | 035de9f0ffe1bca76631b3459dab6dc64179ca60 /Lib/ctypes/test | |
parent | cc0cfd357611c69a99841f21affa73e829416789 (diff) | |
download | cpython-da0eca427aef6c58f3c134c0789f54d7b8fa4210.zip cpython-da0eca427aef6c58f3c134c0789f54d7b8fa4210.tar.gz cpython-da0eca427aef6c58f3c134c0789f54d7b8fa4210.tar.bz2 |
Issue #8966: If a ctypes structure field is an array of c_char, convert its
value to bytes instead of str (as done for c_char and c_char_p).
Diffstat (limited to 'Lib/ctypes/test')
-rw-r--r-- | Lib/ctypes/test/test_bytes.py | 4 | ||||
-rw-r--r-- | Lib/ctypes/test/test_structures.py | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Lib/ctypes/test/test_bytes.py b/Lib/ctypes/test/test_bytes.py index 374b2d7..4a1d0fd 100644 --- a/Lib/ctypes/test/test_bytes.py +++ b/Lib/ctypes/test/test_bytes.py @@ -30,8 +30,8 @@ class BytesTest(unittest.TestCase): X("abc") x = X(b"abc") - self.assertEqual(x.a, "abc") - self.assertEqual(type(x.a), str) + self.assertEqual(x.a, b"abc") + self.assertEqual(type(x.a), bytes) def test_struct_W(self): class X(Structure): diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py index c58d949..fb048aa 100644 --- a/Lib/ctypes/test/test_structures.py +++ b/Lib/ctypes/test/test_structures.py @@ -209,9 +209,9 @@ class StructureTestCase(unittest.TestCase): self.assertRaises(TypeError, Person, "Name", "HI") # short enough - self.assertEqual(Person("12345", 5).name, "12345") + self.assertEqual(Person("12345", 5).name, b"12345") # exact fit - self.assertEqual(Person("123456", 5).name, "123456") + self.assertEqual(Person("123456", 5).name, b"123456") # too long self.assertRaises(ValueError, Person, "1234567", 5) @@ -269,9 +269,9 @@ class StructureTestCase(unittest.TestCase): p = Person("Someone", ("1234", "5678"), 5) - self.assertEqual(p.name, "Someone") - self.assertEqual(p.phone.areacode, "1234") - self.assertEqual(p.phone.number, "5678") + self.assertEqual(p.name, b"Someone") + self.assertEqual(p.phone.areacode, b"1234") + self.assertEqual(p.phone.number, b"5678") self.assertEqual(p.age, 5) def test_structures_with_wchar(self): |