Strange Python COM behaviour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • a_bogdan_marinescu

    Strange Python COM behaviour

    Hello all,

    I'm trying to do some COM automation from Python (using Mark
    Hammond's Win32 extensions, of course) and I'm getting some very
    strange errors. Specifically, I try to use a COM object that supports
    events, and I'm instantiating it like this:

    eventobj = win32com.client .DispatchWithEv ents( crtthread,
    DebuggerThreadE vents )

    When I try to do this, I get the following error:

    ....
    File "d:\work\script s\automation\au tobuild.py", line 106, in
    execute_one_fil e
    eventobj = win32com.client .DispatchWithEv ents( crtthread,
    DebuggerThreadE vents )
    File "C:\Python23\li b\site-packages\win32c om\client\__ini t__.py",
    line 264, in DispatchWithEve nts
    result_class = new.classobj("C OMEventClass", (disp_class,
    events_class, user_event_clas s), {"__setattr_ _" : _event_setattr_ })
    TypeError: str() takes at most 1 argument (3 given)

    It seems that events_class's type is str ( as returned by
    getevents() function in __init__.py file from win32com/Client
    directory) instead of 'classobj' as it is supposed to be. event_class
    is actually a simple string showing a CLSID. I'm new to COM and I
    can't understand why this is happening. Please help me if you can.
    Regards,

    Bogdan Marinescu


  • Mark Hammond

    #2
    Re: Strange Python COM behaviour

    a_bogdan_marine scu wrote:[color=blue]
    > Hello all,
    >
    > I'm trying to do some COM automation from Python (using Mark
    > Hammond's Win32 extensions, of course) and I'm getting some very
    > strange errors. Specifically, I try to use a COM object that supports
    > events, and I'm instantiating it like this:
    >
    > eventobj = win32com.client .DispatchWithEv ents( crtthread,
    > DebuggerThreadE vents )
    >
    > When I try to do this, I get the following error:
    >
    > ...
    > File "d:\work\script s\automation\au tobuild.py", line 106, in
    > execute_one_fil e
    > eventobj = win32com.client .DispatchWithEv ents( crtthread,
    > DebuggerThreadE vents )
    > File "C:\Python23\li b\site-packages\win32c om\client\__ini t__.py",
    > line 264, in DispatchWithEve nts
    > result_class = new.classobj("C OMEventClass", (disp_class,
    > events_class, user_event_clas s), {"__setattr_ _" : _event_setattr_ })
    > TypeError: str() takes at most 1 argument (3 given)
    >
    > It seems that events_class's type is str ( as returned by
    > getevents() function in __init__.py file from win32com/Client
    > directory) instead of 'classobj' as it is supposed to be. event_class
    > is actually a simple string showing a CLSID. I'm new to COM and I
    > can't understand why this is happening. Please help me if you can.
    > Regards,[/color]

    It looks to me as if this error could occur if the event interface you
    are trying to implement is not based on IDispatch. It looks like a bug
    in win32com - what is the object you are trying to use?

    Mark.

    Comment

    Working...