[python-win32] Problem passing a VARIANT argument to a method of aCOM object

Mark Hammond mhammond at skippinet.com.au
Mon Feb 6 22:33:14 CET 2006


> I tried changing the 30 to 8 in the above line. This
> does *not* work either, although it gives a different
> error this time:
>
> >>> obj.AddTest('IsBuy', True)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File
> "c:\Python24\lib\site-packages\win32com\gen_py\98B8AE14-466F-11D6-
> A27B-00B0D0F3CCA6x0x1x0.py",
> line 610, in AddTest
>     return self._oleobj_.InvokeTypes(4, LCID, 1, (24,
> 0), ((8, 1), (12, 1)),lpProperty, vValue)
> pywintypes.com_error: (-2147352568, 'Bad variable
> type.', None, None)
>
>
> > Actually, better yet - if it *does* work, please
> > open a new pywin32 bug at
> > sourceforge.  If it *doesn't* work it may point at
> > an error in the COM
> > object.
>
>
> I am not familiar with COM/pywin much.. so please bear
> with my ignorance..
>
> Does the error above show with some certainty that
> it's a problem with the COM object?

Sadly it doesn't demonstrate much with any certainty!

> I looked at the other COM objects in the API package
> that this particular COM object belongs to. A few
> other objects have a similar method that is documented
> to accept a String and a Variant argument. They work
> fine.
>
> Their definitions in the makepy generated file look
> like this:
>
> 	def Set(self, vKey=defaultNamedNotOptArg,
> newVal=defaultNamedNotOptArg):
> 		"""method Set"""
> 		return self._oleobj_.InvokeTypes(4, LCID, 1, (24,
> 0), ((12, 1), (12, 1)),vKey, newVal)
>
> And these methods seem to work just fine. Is this
> sufficient evidence to say that the AddTest method is
> incorrectly implemented?

That is strange - any of their methods correct use a string, but AddTest
appears to spell it in a different way.  Is it possible for you to contact
the authors of this object?

Mark



More information about the Python-win32 mailing list