Skip to content
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

pushing Python list value as COM parameter only sends NA/Empty values #233

Closed
syoo47 opened this issue May 23, 2021 · 6 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@syoo47
Copy link

syoo47 commented May 23, 2021

I'm using Python 3.9.4 64-bit, with comtypes library 1.1.10. Making a method call on a COM object with a list variable as a parameter results in an empty VARIANT array to be received by the COM object. The array has the right number of elements to match the original list object, but each element is empty/NA.

This was also happening with comtypes library 1.1.8.

@syoo47
Copy link
Author

syoo47 commented May 24, 2021

Did some more testing. comtypes library only seems to fail on python 3.8 or above. 3.7 works just fine.

@vasily-v-ryabov
Copy link
Collaborator

Looks like duplication of #212

@vasily-v-ryabov vasily-v-ryabov added the duplicate This issue or pull request already exists label May 28, 2021
@syoo47
Copy link
Author

syoo47 commented May 28, 2021

vasily, thanks for the heads up. I was able to test your suggested workaround (using tagVARIANT) and it seems to work now under Python 3.9. Thanks again!

@syoo47 syoo47 closed this as completed May 28, 2021
@vasily-v-ryabov
Copy link
Collaborator

@syoo47 can you attach your C++ example code that can reproduce the issue without any debugger?

@syoo47
Copy link
Author

syoo47 commented Jul 23, 2021

It would be hard to provide the C++ code for this as it's an entire COM Automation server and is fairly large. I'd have to create an entire test automation server in order to reproduce this issue.

Besides, it's not a problem on the C++ side (com server). It's a problem on the python side (com client) that is trying to push a simple list array as a single parameter to the com object using comtypes library. On the C++ side, the variant is received as an array with the right number of elements, but each element is empty. By converting the list object explicitly to a tagVARIANT object, the COM call now works:

#the following sends an empty array list
col_data = obj[col].tolist()
app.PutSeries(col, col_data)
#the following sends the appropriate array data
col_data = automation.tagVARIANT(obj[col].tolist())
app.PutSeries(col, col_data)

If you want to reproduce this, get a demo license for EViews, then download and install the pyeviews-1.0.2 python library (not the latest), and then try the examples mentioned in the pyeviews documentation.

@vasily-v-ryabov
Copy link
Collaborator

@syoo47 thanks! I will make next attempt next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants