Thanks for the report. I'll try and take a look at this over the weekend - feel free to open a bug though so it doesn't get lost.
I'd guess that we're (IronPython) doing something wrong with the signature of MaxLColumnDefine which probably defines its parameter types. Either that or we've got the signature right but we should support passing the ubyte_array (ubyte*) (and it looks like any other array) by ref to the c_char_array_array (char**). It's possible that maybe we support passing a char* by ref to a char** but the difference between ubyte (or double) and char is preventing it when it shouldn't - maybe char* gets treated like a universal buffer type, or maybe pointers just easily coerce no matter what they are. If you could look at the different types used in the parameters or in the fields of your Union and compare them between CPython and IronPython that'd probably be useful. Or even just how MaxLColumnDefine is created would be useful. From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of David Welden Sent: Thursday, March 17, 2011 2:41 PM To: Users@lists.ironpython.com Subject: Re: [IronPython] Issue with ctypes arrays of c_ubyte OK. Looks like arrays of doubles and ubytes are not processed by IronPython ctypes as they are in CPython. The error always come back as: "expected c_char_Array_1025_Array_1, got c_ubyte_Array_1" or "expected c_char_Array_1025_Array_1, c_double_Array_1". If I ignore the 'error' as follows: try: sts = maxl.MaxLColumnDefine(sid, c_ulong(index + 1), pInBuff, c_ushort(Size), c_ulong(Type), c_ushort(MAX_REC), None, None) except ArgumentError, e: pass then the output is the same as on CPython. The other deviation I notice is extracting the value of pBuffer.pszVal. With CPython the correct code is: print pBuffer.pszVal[0].value which results in an error in IronPython: 'str' object has no attribute 'value' IronPython ctypes wants this line to be: print pBuffer.pszVal[0] On Tue, Mar 15, 2011 at 1:27 PM, David Welden <dwoo...@gmail.com<mailto:dwoo...@gmail.com>> wrote: I have a ctypes module that is failing under Iron Python. The module is hosted at http://essbasepy.googlecode.com if anyone wants to view the source. I have a union defined as: class output_buffer(Union): _fields_ = [('pdVal', c_double * MAX_REC), ('pbVal', c_ubyte * MAX_REC), ('pszVal', col_t * MAX_REC)] When attempting to use the pbVal field as follows: elif pDescr.IntTyp == MAXL_DTINT_BOOL: pInBuff = pBuffer.pbVal Type = MAXL_DTEXT_UCHAR Size = 0 ... sts = maxl.MaxLColumnDefine(sid, c_ulong(index + 1), pInBuff, c_ushort(Size), c_ulong(Type), c_ushort(MAX_REC), None, None) the called c module fails with the following exception: clsException in System.Collections.ListDictionaryInternal e {expected c_char_Array_1025_Array_1, got c_ubyte_Array_1} object {IronPython.Runtime.Exceptions.PythonExceptions.BaseException} Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal} Message "expected c_char_Array_1025_Array_1, got c_ubyte_Array_1" string Source "IronPython.Modules" string StackTrace " at IronPython.Modules.ModuleOps.CheckCDataType(Object o, Object type)\r\n at InteropInvoker(IntPtr , Object , Object , Object , Object , Object , Object , Object , Object , Object[] )\r\n at CallSite.Target(Closure , CallSite , Object , Object , Object , Object , Object , Object , Object , Object , Object )\r\n at Microsoft.Scripting.Interpreter.DynamicInstruction`10.Run(InterpretedFrame frame)\r\n at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)\r\n at Microsoft.Scripting.Interpreter.LightLambda.Run11[T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)\r\n at Essbase$2._MaxlOutputNextRecord$70(PythonFunction $function, Object self, Object sid, Object ssnInit, Object numFlds) in C:\\Program Files\\IronPython 2.7\\lib\\site-packages\\Essbase.py:line 376" string TargetSite {CData CheckCDataType(System.Object, System.Object)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo} I am a little out of my depth here, so hoping someone understands ctypes in general and the Iron Python implementation in particular.
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com