Invalid __str__ method from makepy
gswifort opened this issue · comments
gswifort commented
makepy generates a __str__
method, which internally calls the __call__
method. The __call__
method can take arguments, while the __str__
method does not take arguments by default - str(obj) ↔ obj.__str__()
.
pywin32/com/win32com/client/genpy.py
Lines 661 to 664 in f7d0a79
This works incorrectly, e.g. for the COM interface of an Autocad application where __call__
requires an Index
argument.
# Default method for this class is 'Item'
def __call__(self, Index=defaultNamedNotOptArg):
'Gets the member object at a given index in a collection, group, or selection set'
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((12, 1),),Index
)
if ret is not None:
ret = Dispatch(ret, '__call__', '{AB9F53A4-BA00-499B-BE4C-D178EC67FFCC}')
return ret
def __str__(self, *args):
return str(self.__call__(*args))
def __int__(self, *args):
return int(self.__call__(*args))
the same goes for __int__
.
The __str__
and __int__
methods seem unnecessary for COM interfaces.