[python-win32] Re: Desire information about Invoke and InvokeTypes

Thomas Heller theller at python.net
Tue Apr 20 07:48:26 EDT 2004


>> Here's the method code generated for Add by the dispatch module:
>>
>> def Add(self, Source=pythoncom.Missing, Rowcol=2,
>> SeriesLabels=pythoncom.Missing, CategoryLabels=pythoncom.Missing,
>> Replace=pythoncom.Missing):
>>          ret = self._oleobj_.InvokeTypes(181, LCID, 1, (9,
>> 0), ((12, 1),
>> (3, 49), (12, 17), (12, 17), (12, 17)),Source, Rowcol, SeriesLabels,
>> CategoryLabels, Replace)
>>          if ret is not None:
>>                  ret = Dispatch(ret, 'Add',
>> '{0002086B-0000-0000-C000-000000000046}', UnicodeToString=0)
>>          return ret
>>
>> The call to InvokeTypes returns integer 1 rather than a
>> PyIDispatch object.
>
> The relevant information is:
>
> (9, 0), ((12, 1), (3, 49), (12, 17), (12, 17), (12, 17))
>
> The (9,0) is the return type.  This translates to VT_DISPATCH.

So the docs also have swapped the typeDesc and the resultTypeDesc
arguments.  It should read
  InvokeTypes(dispid, lcid, wFlags, resultTypeDesc, typeDesc, args)
instead.

> Is it possible you are tripping over us calling the 'default' method or
> property in some cases?  eg:, I could imagine:
>
> sc = chart.SeriesCollection()
> n = sc.Add(series_range, seriesAddDirection)
> print n
>
> would print '1' in certain cases.  However:
> print repr(n)
>
> Would make it more obvious.  It is possible the object has a 'default'
> property that is called whenever str() or int() is called on the object.

I also was bugged by this behaviour some time ago.  Confusing, imo.

Thomas




More information about the Python-win32 mailing list