[Python-checkins] bpo-37571: Add 'b' to prevent the TypeError exception. (GH-14721)
Miss Islington (bot)
webhook-mailer at python.org
Sun Jul 14 04:08:52 EDT 2019
https://github.com/python/cpython/commit/d7caf75c73626d7df4c0628c63761738b7063463
commit: d7caf75c73626d7df4c0628c63761738b7063463
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-07-14T01:08:48-07:00
summary:
bpo-37571: Add 'b' to prevent the TypeError exception. (GH-14721)
Co-Authored-By: Kyle Stanley <aeros167 at gmail.com>
(cherry picked from commit 6b929580eb018cfef386db7f7f66b3a58532eada)
Co-authored-by: Michele Angrisano <michele.angrisano at gmail.com>
files:
M Doc/library/ctypes.rst
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 46a9d23ac392..b5dfaa00c1d6 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.
More information about the Python-checkins
mailing list