[python-win32] win32com gencache InvokeTypes and OUT/ByRef parameters

Mark Hammond skippy.hammond at gmail.com
Fri Jun 12 07:55:15 CEST 2009


On 12/06/2009 6:58 AM, Hibiki Kanzaki wrote:
> I am using a COM library from Python.  The methods
> have OUT parameters, so I am using the gencache/makepy
> facility of win32com.  When it generates the wrapper
> files, there are function definitions like this one
> (this is for accessing Visual SourceSafe COM Automation)
>
> 	# Result is of type IVSSItem
> 	# The method VSSItem is actually a property, but must be used as a
> method to correctly pass the arguments
> 	def VSSItem(self, Spec=defaultNamedNotOptArg, Deleted=False):
> 		ret = self._oleobj_.InvokeTypes(6, LCID, 2, (9, 0), ((8, 1), (11, 49)),Spec
> 			, Deleted, ppIVSSItem)
> 		if ret is not None:
> 			ret = Dispatch(ret, u'VSSItem', '{2A0DE0E7-2E9F-11D0-9236-00AA00A1EB95}')
> 		return ret

Thanks for the detailed report and analysis.  Sadly I can't reproduce 
this problem.  I even found the IDL for VSSItem at 
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.sourcesafe.interop.ivssdatabase.vssitem(VS.80).aspx 
and added the same IDL to the test suite (which already had something 
*very* close), but it works fine.


In that same module you mentioned, _BuildArgList() is reponsible for 
that extra name:

def _BuildArgList(fdesc, names):
     "Builds list of args to the underlying Invoke method."
     # Word has TypeInfo for Insert() method, but says "no args"
     numArgs = max(fdesc[6], len(fdesc[2]))
...

but what should be happening is that 'ppIVSSItem' should not appear in 
the list of 'names' at all - it is a return value.  It should also not 
appear in 'fdesc[6]' (a list of tuples, one for each arg) and it isn't - 
the generated code you pasted shows fdesc[6] is '((8, 1), (11, 49))', so 
correctly has only 2 args.

after lots of going around in circles, I suspect that last line above is 
the problem: if you change that to simply:

     numArgs = len(fdesc[2])

does the problem go away?  I'm not sure that is the correct solution in 
all cases, but it would be good to know how it works in this case...

Cheers,

Mark


More information about the python-win32 mailing list