New submission from Lenard Lindstrom: When a callback is created with an array argument and then is called from Python the callback function receives an array full of garbage.
Here is an example: Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> A = c_int * 1 >>> A <class '__main__.c_long_Array_1'> >>> Foo = CFUNCTYPE(None, A) >>> def py_foo(a): ... print a ... print a[0] ... >>> foo = Foo(py_foo) >>> foo(A(42)) <__main__.c_long_Array_1 object at 0x00B54440> 11879448 It works correctly when the callback is declared with a pointer argument instead: >>> A = c_int * 1 >>> Foo = CFUNCTYPE(None, POINTER(c_int)) >>> def py_foo(p): ... print p ... print p[0] ... >>> foo = Foo(py_foo) >>> foo(A(42)) <ctypes.LP_c_long object at 0x00B54440> 42 ---------- components: Library (Lib), Windows messages: 59759 nosy: kermode severity: normal status: open title: ctypes callback fails when called in Python with array argument type: behavior versions: Python 2.5 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1800> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com