Author: thomas.heller Date: Thu Jul 12 21:38:33 2007 New Revision: 56331 Modified: python/branches/py3k-struni/Lib/ctypes/test/test_prototypes.py python/branches/py3k-struni/Modules/_ctypes/_ctypes.c Log: c_void_p.from_param accepts bytes. Fix test_prototypes.
Modified: python/branches/py3k-struni/Lib/ctypes/test/test_prototypes.py ============================================================================== --- python/branches/py3k-struni/Lib/ctypes/test/test_prototypes.py (original) +++ python/branches/py3k-struni/Lib/ctypes/test/test_prototypes.py Thu Jul 12 21:38:33 2007 @@ -104,7 +104,7 @@ 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))) Modified: python/branches/py3k-struni/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k-struni/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k-struni/Modules/_ctypes/_ctypes.c Thu Jul 12 21:38:33 2007 @@ -1268,6 +1268,7 @@ } return (PyObject *)parg; } + /* XXX struni: remove later */ /* string */ if (PyString_Check(value)) { PyCArgObject *parg; @@ -1285,6 +1286,23 @@ } 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; _______________________________________________ Python-3000-checkins mailing list Python-3000-checkins@python.org http://mail.python.org/mailman/listinfo/python-3000-checkins