I'm invoking a method of COM object with string argument using comtypes
and method returns (it should return a COM string):
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-102-009507ff0086> in <module>()
----> 1 obj1=xobjData.GetDataType('string_name')
C:\Python\Python27\lib\site-packages\comtypes\__init__.pyc in call_with_inout(self_, *args, **kw)
657 # be iterable.
658 if len(outargs) == 1: # rescode is not iterable
--> 659 return rescode.__ctypes_from_outparam__()
660
661 rescode = list(rescode)
AttributeError: 'tuple' object has no attribute '__ctypes_from_outparam__'
Seems very cryptic error, any help?
%debug
magic shows following:
> c:\python\python27\lib\site-packages\comtypes\__init__.py(659)call_with_inout()
658 if len(outargs) == 1: # rescode is not iterable
--> 659 return rescode.__ctypes_from_outparam__()
660
ipdb> outargs
{0: VARIANT(vt=0x8, u'string_name')}
ipdb> rescode
(VARIANT(vt=0x8, u'string_name'), u'Long')
ipdb> print(dir(outargs))
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values', 'viewitems', 'viewkeys', 'viewvalues']
ipdb> print(dir(rescode))
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']
ipdb> u
> <ipython-input-112-83ed14b8961f>(1)<module>()
----> 1 xobjData.GetDataType(u'string_name')
ipdb> d
> c:\python\python27\lib\site-packages\comtypes\__init__.py(659)call_with_inout()
658 if len(outargs) == 1: # rescode is not iterable
--> 659 return rescode.__ctypes_from_outparam__()
660
ipdb> exit
This is a bug in comtypes, see fix here: