New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win32com.client returns objects witht he wrong interface when using makepy generated modules #1699
Comments
I think I found why the code does not work: https://docs.python.org/3/reference/datamodel.html#special-lookup Special methods are not looked up through It occurs to me, that to make the mechanism work, the property class type could be defined somehow similarly to this instead: class GuiComponentCollection(ISapCollectionTarget):
CLSID = IID('{A464F5B4-CC70-4062-A0A1-6DC9B461D776}') but I admit that I didn't spend too much time analyzing what a |
If that wasn't true in 2.x, then it's probably a regression. I'd expect to find some tests for this in the |
Assuming that you mean a Python 3.x vs 2.x regression, the behavior for what were "new style classes" in Python 2.x has not changed. However, "new style classes" were opt-in in Python 2.x while they are the only flavor of classes available in Python 3.x. The less invasive solution would be to have the generated classes have In the meanwhile, is there a way to use COM events without the generated modules? |
Thanks - I pushed a work-around in 17fb589.
Not that I'm aware of :( |
I am using Python 3.8.8 and pywin32 227 on Windows 10. I am trying to do some SAP GUI scripting in Python. All goes well when I don't generate the python modules for the COM interfaces and I rely on dynamic dispatch, however, things break when win32com.client invokes makepy.
A simple example to demonstrates the issue:
works. However, after running makepy for the relevant COM module, the same code raises an exception:
Inspecting the module generated by makepy, the
Connection
property is defined like this:which I think corresponds to this class:
and this interface:
which seems to implement the right methods and Python interfaces (by the way, it would be cool if
__getitem__
could also be implemented for COM interfaces exposing containers). However, I don't really understand how all the pieces are supposed to be glued together, and thus why it does not work as intended. TheConnections
property return the right type:The same think happens for all other properties that return a COM object. I can go on with dynamic dispatching just fine, without the generated modules, but the generated modules are necessary (or at least they built is triggered by) using event dispatching, thus I am kind of stuck.
Please let me know if there is anything more I can provide to help debug the issue.
The text was updated successfully, but these errors were encountered: