Skip to content

Commit 6b92958

Browse files
mangrisanoaeros
authored andcommitted
bpo-37571: Add 'b' to prevent the TypeError exception. (GH-14721)
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
1 parent 8efade9 commit 6b92958

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Doc/library/ctypes.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,12 +1178,17 @@ the root-object's underlying buffer.
11781178
Another example that may behave different from what one would expect is this::
11791179

11801180
>>> s = c_char_p()
1181-
>>> s.value = "abc def ghi"
1181+
>>> s.value = b"abc def ghi"
11821182
>>> s.value
1183-
'abc def ghi'
1183+
b'abc def ghi'
11841184
>>> s.value is s.value
11851185
False
1186-
>>>
1186+
>>>
1187+
1188+
.. note::
1189+
1190+
Objects instantiated from :class:`c_char_p` can only have their value set to bytes
1191+
or integers.
11871192

11881193
Why is it printing ``False``? ctypes instances are objects containing a memory
11891194
block plus some :term:`descriptor`\s accessing the contents of the memory.

0 commit comments

Comments
 (0)