Bugs item #797078, was opened at 2003-08-28 22:42
Message generated for change (Settings changed) made by gcash
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=797078&group_id=78018
Category: com
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Gene Cash (gcash)
Assigned to: Nobody/Anonymous (nobody)
Summary: WithEvents interferes with IE "frames" attribute
Initial Comment:
It seems that if you use WithEvents, that the IE
Document object
"frames" attribute has problems. The "frames" attribute
is the
collection of the "documents" objects for each of the
subframes.
Example 1 - "correct" behaviour w/o events
>>> import win32com.client as wc
>>> ie=wc.Dispatch('InternetExplorer.Application.1')
>>> ie.Visible=1
>>>
ie.Navigate('http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=37835B30.BFCC4A05%40phoenix-edv.netzservice.de&rnum=5&prev=/groups%3Fas_q%3Dwin32%26safe%3Dimages%26ie%3DUTF-8%26oe%3DUTF-8%26as_ugroup%3Dcomp.lang.python%26lr%3D%26hl%3Den')
>>> ie
<COMObject InternetExplorer.Application.1>
>>> ie.Document.links
<COMObject <unknown>>
>>> ie.Document.links.length
0
>>> ie.Document.frames
<COMObject <unknown>>
>>> ie.Document.frames.length
1
>>> ie.Document.frames[0].name
u'left'
>>> ie.Document.frames[1].name
u'right'
Example 2 - 'No such interface supported' crash using
events
>>> import win32com.client as wc
>>>
ie_class=wc.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',
0, 1, 1)
>>> class IE_Events(ie_class.DWebBrowserEvents2):
>>> pass
>>>
ie=wc.DispatchWithEvents('InternetExplorer.Application.1',
IE_Events)
>>> ie.Visible=1
>>>
ie.Navigate('http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=37835B30.BFCC4A05%40phoenix-edv.netzservice.de&rnum=5&prev=/groups%3Fas_q%3Dwin32%26safe%3Dimages%26ie%3DUTF-8%26oe%3DUTF-8%26as_ugroup%3Dcomp.lang.python%26lr%3D%26hl%3Den')
>>> ie
<win32com.gen_py.Microsoft Internet
Controls.IWebBrowser2 instance at 0x8296408>
>>> ie.Document.links
<COMObject <unknown>>
>>> ie.Document.links.length
0
>>> ie.Document.frames
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"C:\Python\lib\site-packages\win32com\client\dynamic.py",
line 454, in __
getattr__
raise pythoncom.com_error, details
pywintypes.com_error: (-2147467262, 'No such interface
supported', None, None)
>>>
What's strange is the "forms" & "links" attributes
still work, even
though they're object collections as well. I saw in
Google that
"vtable" support is iffy... how do you tell if
something is a "vtable"
interface?
Now even if I change to attaching an event class by:
>>> ie=wc.Dispatch('InternetExplorer.Application.1')
>>> IE_Events(ie)
It crashes the same way.
Or if I change the event class to:
>>> class
IE_Events(wc.getevents('InternetExplorer.Application.1')):
>>> pass
it also crashes the same way.
The first example has no problem with makepy support
being present.
Any ideas? This is on a fresh Win2k Pro box with SP4
and all the
critical patches applied via Windows Update.
I can reproduce this in builds 154, 155, 156, and 157
(with the
appropriate version of Python) The above line number is
build 157, I
think.
I've looked at the code for getevents(), Dispatch(), and
DispatchWithEvents() and I'm not a good enough Windows
hacker to see a
problem.
- Gene Cash gc...@cf... / gen...@or...
----------------------------------------------------------------------
Comment By: Gene Cash (gcash)
Date: 2003-08-29 14:07
Message:
Logged In: YES
user_id=141974
OK, it appears I just needed to read Appendix D of The Book,
where it discusses threading, especially "What are the
apartment rules". On the other hand, I now actually
understand it, where before it was gibberish.
I have learned to read the Dark Runes. Does this mean I no
longer have a soul?
WithEvents() starts another thread, so parentWindow & Frames
- which are COM pointers - can't be passed between the threads.
I'll close this one.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=797078&group_id=78018
|