Commit 3821e31d authored by Thomas Heller's avatar Thomas Heller

c_void_p.from_param accepts bytes. Fix test_prototypes.

parent 3d79dd9e
......@@ -104,7 +104,7 @@ class CharPointersTestCase(unittest.TestCase):
func.argtypes = c_void_p,
self.failUnlessEqual(None, func(None))
self.failUnlessEqual("123", func("123"))
self.failUnlessEqual("123", func(b"123"))
self.failUnlessEqual("123", func(c_char_p("123")))
self.failUnlessEqual(None, func(c_char_p(None)))
......
......@@ -1268,11 +1268,29 @@ c_void_p_from_param(PyObject *type, PyObject *value)
}
return (PyObject *)parg;
}
/* XXX struni: remove later */
/* string */
if (PyString_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;
}
/* bytes */
if (PyBytes_Check(value)) {
PyCArgObject *parg;
struct fielddesc *fd = getentry("z");
parg = new_CArgObject();
if (parg == NULL)
return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment