Skip to content

Fix dispatch handling for properties#2506

Merged
mhammond merged 3 commits intomhammond:mainfrom
the-snork:dispatch_cast
Apr 14, 2025
Merged

Fix dispatch handling for properties#2506
mhammond merged 3 commits intomhammond:mainfrom
the-snork:dispatch_cast

Conversation

@the-snork
Copy link
Copy Markdown
Contributor

See the following pseudo code (IDL):

[...]
interface IFoo : IDispatch
{
    HRESULT Bar();
}

interface IHolder
{
    [propget]HRESULT Foo
    {
        [out, retval]IFoo **foo
    };
}

When importing above with makepy, the following fails in Python

foo = holder.Foo
foo.Bar()

due to member not found, while this works:

foo = holder.Foo
fooWrapped = IFoo(foo)
fooWrapped.Bar()

This pull request is for enabling the first variant, too.

The problem is the intermediate dynamic wrapper.

Comment thread com/win32com/client/__init__.py Outdated
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?

Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

thanks

@mhammond mhammond merged commit 25e01da into mhammond:main Apr 14, 2025
30 checks passed
geppi added a commit to geppi/pywin32 that referenced this pull request Jul 20, 2025
mhammond pushed a commit that referenced this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants