diff options
author | Michele Angrisano <michele.angrisano@gmail.com> | 2019-07-14 07:55:11 (GMT) |
---|---|---|
committer | Steve Dower <steve.dower@python.org> | 2019-07-14 07:55:11 (GMT) |
commit | 6b929580eb018cfef386db7f7f66b3a58532eada (patch) | |
tree | 536657bf5950a1a0b05ba72dd89ff66f8d33c4b7 /Doc/library | |
parent | 8efade91b12a13102a09a3856179021e579da5e9 (diff) | |
download | cpython-6b929580eb018cfef386db7f7f66b3a58532eada.zip cpython-6b929580eb018cfef386db7f7f66b3a58532eada.tar.gz cpython-6b929580eb018cfef386db7f7f66b3a58532eada.tar.bz2 |
bpo-37571: Add 'b' to prevent the TypeError exception. (GH-14721)
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/ctypes.rst | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 680703d..5507cc6 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1178,12 +1178,17 @@ the root-object's underlying buffer. Another example that may behave different from what one would expect is this:: >>> s = c_char_p() - >>> s.value = "abc def ghi" + >>> s.value = b"abc def ghi" >>> s.value - 'abc def ghi' + b'abc def ghi' >>> s.value is s.value False - >>> + >>> + +.. note:: + + Objects instantiated from :class:`c_char_p` can only have their value set to bytes + or integers. Why is it printing ``False``? ctypes instances are objects containing a memory block plus some :term:`descriptor`\s accessing the contents of the memory. |