I figured out when this happens. It happens when you try to pass an array 
into an arg that requires a Record.

I am really confused as to how this all works, but will start trying to find 
some info on what is going on.

Form what I can see, the code in the makepy generated file is trying to take 
python datatypes and map them into the required. So I need to figure out how 
to use a Record then.

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.

Meh

thanks though

Rex




From: "Mark Hammond" <[EMAIL PROTECTED]>
To: "'Rex Corrovan'" <[EMAIL PROTECTED]>,<python-win32@python.org>
Subject: RE: [python-win32] MemoryError: CreatingSafeArray when trying to 
use VBCOM API
Date: Wed, 10 Jan 2007 14:32:57 +1100



 > -----Original Message-----
 > From: [EMAIL PROTECTED]
 > [mailto:[EMAIL PROTECTED] Behalf Of Rex Corrovan
 > Sent: Wednesday, 10 January 2007 7:54 AM
 > To: python-win32@python.org
 > Subject: [python-win32] MemoryError: CreatingSafeArray when trying to
 > use VBCOM API
 >
 >
 > I have a VB COM App I am trying to use.
 >
 > I used makepy and it generated the wrapper. Then I go to use:
 >
 > import win32com.client
 > o = win32.client.Dispatch("vbAPI.App")
 >
 > o.myFunct(arg1=("test","test"), arg2=1, arg3=("test2","test2"))
 >
 >
 > The function in the makepy generated wrapper looks like this:
 >
 > def myFunct(self, arg1=defaultNamedNotOptArg,
 > arg2=defaultNamedNotOptArg,
 > arg3=defaultNamedNotOptArg):
 >     return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584,
 > 3), (11, 1),
 > (24612, 3)), 'myFunct', None, arg1, arg2, arg3)
 >
 >
 > The output I get is:
 >
 > Traceback (most recent call last):
 >   File "<interactive input>", line 1, in ?
 >   File
 > "C:\Python24\lib\site-packages\win32com\gen_py\0A54F42C-8CBC-4
 > C09-9F6B-C976C6476689x0x1x1.py",
 > line 43, in myFunct
 >     return self._ApplyTypes_(1610809344, 1, (8, 0), ((24584,
 > 3), (11, 1),
 > (24612, 3)), 'myFunct', None, arg1
 >   File
 > "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line
 > 446, in _ApplyTypes_
 >     return self._get_good_object_(
 > MemoryError: CreatingSafeArray

This error is raised when the Windows function SafeArrayCreate fails.  I'm
surprised this is the case - your arrays are very small - but that is the
only way this error will be raised.

I'm afraid the only advice I can offer is to try and modify the VB test
suite to provoke the same error.  You will need vb6 and the pywin32 source
distro to build the test COM object (in com\TestSources), then use
win32com\test\testvb.py to exercise it.  That would allow me to reproduce it
here.  You might also be able to send me the control, and I could at least
verify the params we are passing to SafeArrayCreate are sane.

Mark

_________________________________________________________________
>From photos to predictions, The MSN Entertainment Guide to Golden Globes has 
it all. http://tv.msn.com/tv/globes2007/?icid=nctagline1

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to