Skip to content

[3.8] bpo-37571: Add 'b' to prevent the TypeError exception. (GH-14721) #14762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down