summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-08-08 18:47:32 (GMT)
committerThomas Heller <theller@ctypes.org>2007-08-08 18:47:32 (GMT)
commit2fb5ac745bf2edd03261ca8144eb73a1f6e54af3 (patch)
tree411516f988845a5cc4a25c97262dcdab7f1171e4 /Modules
parentdf5f6b551ad89257a579682114ae9f2ab1d3755e (diff)
downloadcpython-2fb5ac745bf2edd03261ca8144eb73a1f6e54af3.zip
cpython-2fb5ac745bf2edd03261ca8144eb73a1f6e54af3.tar.gz
cpython-2fb5ac745bf2edd03261ca8144eb73a1f6e54af3.tar.bz2
Fix the ctypes tests. Patch from Victor Stinner. He writes:
The problem is that ctypes c_char (and c_char_p) creates unicode string instead of byte string. I attached a proposition (patch) to change this behaviour (use bytes for c_char). So in next example, it will display 'bytes' and not 'str': from ctypes import c_buffer, c_char buf = c_buffer("abcdef") print (type(buf[0])) Other behaviour changes: - repr(c_char) adds a "b" eg. repr(c_char('x')) is "c_char(b'x')" instead of "c_char('x')" - bytes is mutable whereas str is not: this may break some modules based on ctypes
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index cc94850..f60dede 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1156,7 +1156,7 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
c_get(void *ptr, Py_ssize_t size)
{
- return PyUnicode_FromStringAndSize((char *)ptr, 1);
+ return PyBytes_FromStringAndSize((char *)ptr, 1);
}
#ifdef CTYPES_UNICODE