summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes/_ctypes.c
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-07-12 19:38:33 (GMT)
committerThomas Heller <theller@ctypes.org>2007-07-12 19:38:33 (GMT)
commit3821e31d19343ff8694f6e2c86c12c0dcd127527 (patch)
treea06791f060a16c02b29298bdef398af5a503185e /Modules/_ctypes/_ctypes.c
parent3d79dd9edf3cfdffd1dc7d4e45b77da2478e1111 (diff)
downloadcpython-3821e31d19343ff8694f6e2c86c12c0dcd127527.zip
cpython-3821e31d19343ff8694f6e2c86c12c0dcd127527.tar.gz
cpython-3821e31d19343ff8694f6e2c86c12c0dcd127527.tar.bz2
c_void_p.from_param accepts bytes. Fix test_prototypes.
Diffstat (limited to 'Modules/_ctypes/_ctypes.c')
-rw-r--r--Modules/_ctypes/_ctypes.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index d6a435d..5b11480 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1268,6 +1268,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
}
return (PyObject *)parg;
}
+ /* XXX struni: remove later */
/* string */
if (PyString_Check(value)) {
PyCArgObject *parg;
@@ -1285,6 +1286,23 @@ c_void_p_from_param(PyObject *type, PyObject *value)
}
return (PyObject *)parg;
}
+/* bytes */
+ if (PyBytes_Check(value)) {
+ PyCArgObject *parg;
+ struct fielddesc *fd = getentry("z");
+
+ parg = new_CArgObject();
+ if (parg == NULL)
+ return NULL;
+ parg->pffi_type = &ffi_type_pointer;
+ parg->tag = 'z';
+ parg->obj = fd->setfunc(&parg->value, value, 0);
+ if (parg->obj == NULL) {
+ Py_DECREF(parg);
+ return NULL;
+ }
+ return (PyObject *)parg;
+ }
/* unicode */
if (PyUnicode_Check(value)) {
PyCArgObject *parg;