Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html .
Coming in build 311, as yet unreleased
--------------------------------------
* Fixed a regression that broke special __dunder__ methods with CoClass. (#1870, #2493, @Avasam, @geppi)
* Fixed dispatch handling for properties (@the-snork)

Build 310, released 2025/03/16
------------------------------
Expand Down
9 changes: 4 additions & 5 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,10 @@ class DispatchBaseClass:
def __init__(self, oobj=None):
if oobj is None:
oobj = pythoncom.new(self.CLSID)
elif isinstance(oobj, DispatchBaseClass):
elif isinstance(oobj, (DispatchBaseClass, _PyIDispatchType)):
try:
oobj = oobj._oleobj_.QueryInterface(
self.CLSID, pythoncom.IID_IDispatch
) # Must be a valid COM instance
oobj = oobj._oleobj_ if isinstance(oobj, DispatchBaseClass) else oobj
oobj = oobj.QueryInterface(self.CLSID, pythoncom.IID_IDispatch)
except pythoncom.com_error as details:
import winerror

Expand All @@ -537,7 +536,7 @@ def __init__(self, oobj=None):
# So just let it use the existing object if E_NOINTERFACE
if details.hresult != winerror.E_NOINTERFACE:
raise
oobj = oobj._oleobj_

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

def __dir__(self):
Expand Down