[python-win32] MemoryError: CreatingSafeArray when trying touse VBCOM API

Mark Hammond mhammond at skippinet.com.au
Thu Jan 11 02:23:44 CET 2007


> if I do:
> s = win32com.client.Record("myStruct", o)
> s.myString = "test"
> s.myInt = 12
>
> o.myFunct(arg1=("test","test"), arg2=1, arg3=s)
>
> it then complains:
> TypeError: Objects for SAFEARRAYS must be sequences (of
> sequences), or a
> buffer object.

In your original mail, you indicated the makepy generated code for the args:

> ((24584, 3), (11, 1), (24612, 3))

Arg1 is an array of strings (as you are passing).  Arg2 is a bool (an int
will work fine, as you have done).  Arg3, 24612==pythoncom.VT_RECORD |
pythoncom.VT_ARRAY | pythoncom.VT_BYREF - so arg3 wants an array of these
records.

Hope this helps,

Mark



More information about the Python-win32 mailing list