comtypes comオブジェクトのメソッドは次を返します: 'tuple'オブジェクトには属性がありません '__ctypes_from_outparam__'

denfromufa

を使用して文字列引数を使用してCOMオブジェクトのメソッドを呼び出していcomtypesます。メソッドは戻ります(COM文字列を返す必要があります)。

---------------------------------------------------------------------------
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__'

非常に不可解なエラーのようです、何か助けはありますか?

%debug 魔法のショーは次のとおりです。

> 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
denfromufa

これはcomtypesのバグです。ここで修正を参照してください:

https://github.com/enthought/comtypes/issues/87

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ