Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,20 @@ def __init__(self, oobj=None):
if details.hresult != winerror.E_NOINTERFACE:
raise
oobj = oobj._oleobj_
elif isinstance(oobj, _PyIDispatchType):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this be slightly better rolled up in the above seeing that it's identical? A changelog entry would be great too!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better like this?

try:
oobj = oobj.QueryInterface(
self.CLSID, pythoncom.IID_IDispatch
) # Must be a valid COM instance
except pythoncom.com_error as details:
import winerror

# Some stupid objects fail here, even tho it is _already_ IDispatch!!??
# Eg, Lotus notes.
# So just let it use the existing object if E_NOINTERFACE
if details.hresult != winerror.E_NOINTERFACE:
raise

self.__dict__["_oleobj_"] = oobj # so we don't call __setattr__

def __dir__(self):
Expand Down