473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.DispatchWithEvents( crtthread,
DebuggerThreadEvents )

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

....
File "d:\work\scripts\automation\autobuild.py", line 106, in
execute_one_file
eventobj = win32com.client.DispatchWithEvents( crtthread,
DebuggerThreadEvents )
File "C:\Python23\lib\site-packages\win32com\client\__init__.py",
line 264, in DispatchWithEvents
result_class = new.classobj("COMEventClass", (disp_class,
events_class, user_event_class), {"__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
Jul 18 '05 #1
1 2501
a_bogdan_marinescu wrote:
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.DispatchWithEvents( crtthread,
DebuggerThreadEvents )

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

...
File "d:\work\scripts\automation\autobuild.py", line 106, in
execute_one_file
eventobj = win32com.client.DispatchWithEvents( crtthread,
DebuggerThreadEvents )
File "C:\Python23\lib\site-packages\win32com\client\__init__.py",
line 264, in DispatchWithEvents
result_class = new.classobj("COMEventClass", (disp_class,
events_class, user_event_class), {"__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,


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.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
Hi, I don't understand this strange behaviour: I compile this code : #include <Python.h> #include"Numeric/arrayobject.h" static PyObject *
4
by: Ben | last post by:
Hi all, I'm trying to figure out how how complex map, filter and reduce work based on the following piece of code from http://www-106.ibm.com/developerworks/linux/library/l-prog.html : ...
2
by: Markus Franz | last post by:
Hi. Today I created a script called load.py for using at the command line written in Python 2.3. This script should load as many websites as given on the comand line and print them with a...
24
by: brian.bird | last post by:
Can anyone explain the behaviour of python when running this script? >>> def method(n, bits=): .... bits.append(n) .... print bits .... >>> method(1) >>> method(2)
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.