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
5 changes: 3 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ https://mhammond.github.io/pywin32_installers.html .

Coming in build 310, as yet unreleased
--------------------------------------
* Drop support for Vista, set Windows 7 as the minimal Windows version. (#, @Avasam)
* Restores many IIDs in `win32com(ext).shell.shell`. See #2486 for details.
* Fixed a regression where `win32com.client.DispatchWithEvents` and win32com.client.WithEvents` would throw a `TypeError` on the second call (#2491, @Avasam)
* Dropped support for Vista, set Windows 7 as the minimal Windows version. (#2487, @Avasam)
* Restored many IIDs in `win32com(ext).shell.shell`. See #2486 for details. (#2487, @Avasam)

Build 309, released 2025/03/09
------------------------------
Expand Down
34 changes: 17 additions & 17 deletions com/win32com/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,24 @@ def __get_disp_and_event_classes(dispatch):
disp = Dispatch(dispatch)

if disp.__class__.__dict__.get("CLSID"):
return disp.__class__
disp_class = disp.__class__
else:
# Eeek - no makepy support - try and build it.
error_msg = "This COM object can not automate the makepy process - please run makepy manually for this object"
try:
ti = disp._oleobj_.GetTypeInfo()
disp_clsid = ti.GetTypeAttr()[0]
tlb, index = ti.GetContainingTypeLib()
tla = tlb.GetLibAttr()
gencache.EnsureModule(tla[0], tla[1], tla[3], tla[4], bValidateFile=0)
# Get the class from the module.
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error as error:
raise TypeError(error_msg) from error

if disp_class is None:
raise TypeError(error_msg)
Comment on lines +287 to +288
Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Mar 11, 2025

Choose a reason for hiding this comment

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

Explanation for moving this check only in the else branch:
It's not possible for disp_class to be None after the if branch.


# Eeek - no makepy support - try and build it.
error_msg = "This COM object can not automate the makepy process - please run makepy manually for this object"
try:
ti = disp._oleobj_.GetTypeInfo()
disp_clsid = ti.GetTypeAttr()[0]
tlb, index = ti.GetContainingTypeLib()
tla = tlb.GetLibAttr()
gencache.EnsureModule(tla[0], tla[1], tla[3], tla[4], bValidateFile=0)
# Get the class from the module.
disp_class = gencache.GetClassForProgID(str(disp_clsid))
except pythoncom.com_error as error:
raise TypeError(error_msg) from error

if disp_class is None:
raise TypeError(error_msg)
# Get the clsid
clsid = disp_class.CLSID
# Create a new class that derives from 2 classes:
Expand Down Expand Up @@ -333,7 +334,6 @@ class object that derives from three classes:
>>> ie = DispatchWithEvents("InternetExplorer.Application", IEEvents)
>>> ie.Visible = 1
Visible changed: 1
>>>
"""
disp, disp_class, events_class = __get_disp_and_event_classes(clsid)
result_class = type(
Expand Down