Index: Lib/ctypes/test/test_callbacks.py =================================================================== --- Lib/ctypes/test/test_callbacks.py (revision 81268) +++ Lib/ctypes/test/test_callbacks.py (working copy) @@ -174,5 +174,22 @@ ################################################################ +class ArrayCallbacks(Callbacks): + def callback(self, a): + self.a0 = a[0] + + def check_type(self, typ, arg): + A = typ * 1 + PROTO = CFUNCTYPE(None, A) + PROTO(self.callback)(A(arg)) + if typ == c_float: + self.assertAlmostEqual(self.a0, arg, places=5) + else: + self.assertEqual(self.a0, arg) + + def test_int(self): + self.check_type(c_int, 42) +################################################################ + if __name__ == '__main__': unittest.main() Index: Lib/ctypes/__init__.py =================================================================== --- Lib/ctypes/__init__.py (revision 81268) +++ Lib/ctypes/__init__.py (working copy) @@ -101,6 +101,16 @@ try: return _c_functype_cache[(restype, argtypes, flags)] except KeyError: + # decay array args to pointers + PyCArrayType = type(c_int * 1) # XXX: Any better way to import PyCArrayType? + arrayargs = [(i, t) for i, t in enumerate(argtypes) + if isinstance(t, PyCArrayType)] + if arrayargs: + argtypeslist = list(argtypes) + for i, t in arrayargs: + argtypeslist[i] = POINTER(t._type_) + argtypes = tuple(argtypeslist) + class CFunctionType(_CFuncPtr): _argtypes_ = argtypes _restype_ = restype