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> 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

Reply via email to