Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#246 TypeError: 'unicode' object is not callable

closed-wont-fix
nobody
com (105)
5
2005-10-23
2005-09-20
Oleg Noga
No

python 2.3.5
pythonwin 204
using dynamic binding

Have TypeError: 'unicode' object is not callable while
calling COM object function. Because
CDispatch.__getattr__ returns empty unicode string
instead of callable.

I made some dirty fix, please, see attach, there is some
comments inside

It is win32com\client\dynamic.py

Pity I can't supply COM object to reproduce because it
is proprietary.

Discussion

  • Oleg Noga
    Oleg Noga
    2005-09-20

    dirty fixed dispatch.py with some comments

     
    Attachments
  • Oleg Noga
    Oleg Noga
    2005-09-20

    Logged In: YES
    user_id=551440

    Note: Visual Basic calls functions of that COM object
    correctly

     
  • Mark Hammond
    Mark Hammond
    2005-10-23

    • status: open --> closed-wont-fix
     
  • Mark Hammond
    Mark Hammond
    2005-10-23

    Logged In: YES
    user_id=14198

    The problem here is that Python tries to check if the
    attribute name is a method or property by requesting a
    property and handling the error that results. Even though
    Python asks specifically for a property
    (INVOKE_PROPERTYGET), the object is treating it as a
    function call and returning a string. pythoncom therefore
    assumes it is a simple property. VB does it correctly as
    its syntax prevents using functions as objects (eg, you
    can't assign an object method to a variable).

    There are 2 choices:
    * Change the object to honour the invoke flags correctly.
    * Call obj._FlagAsMethod("Method1", "method2", ...)

    And you will then be able to say

    obk.Method1()