[IronPython] Issue with ctypes arrays of c_ubyte

David Welden dwoogle at gmail.com
Tue Mar 15 11:27:44 PDT 2011


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20110315/7e07d136/attachment.htm>


More information about the Users mailing list