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

Attempting to import comtypes.viewobject raises AssetionError #446

Open
DManowitz opened this issue Jan 2, 2023 · 3 comments
Open

Attempting to import comtypes.viewobject raises AssetionError #446

DManowitz opened this issue Jan 2, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@DManowitz
Copy link

When I try to import comtypes.viewobject, I get the following error:

  File "<stdin>", line 1, in <module>
  File "C:\Users\manow\miniconda3\envs\py37_ml_TfGpuMain\lib\site-packages\comtypes\viewobject.py", line 26, in <module>
    assert sizeof(tagLOGPALETTE) == 8, sizeof(tagLOGPALETTE)
AssertionError: 12

This occurs with comtypes 1.1.14 using Python 3.7 or 3.8

@junkmd junkmd added the help wanted Extra attention is needed label Jan 2, 2023
@junkmd
Copy link
Collaborator

junkmd commented Jan 3, 2023

comtypes.util is an old module that has not been maintained for a long time, the last modification being 14 years ago.

This package originator, Thomas Heller has stepped down from Python communities and I do not know his current contact information.

However, from the former change diff, it appears that this was migrated from a .py file originally generated in comtypes/gen.
The reason I think so is that the first commit did not import IUnknown from comtypes, but from comtypes.gen._00020430_0000_0000_0000_C000_00000000000046_0_2_0.
If these were defined from scratch, there would be no need for such roundabout imports.

So perhaps this was working well in the originator's 14 year old environment and is not so now.

I am not sure that removing the assert size and alignment checks is the solution.
It may be necessary to change the definitions of various stuffs.

I would like to hear from other participants in this community.

@vasily-v-ryabov
Copy link
Collaborator

It looks like old asserts are valid for 32-bit Python only. For 64-bit Python we need to add conditional asserts. I did similar job for pywinauto a long time ago (between 2010 and 2014).

@DManowitz do you see such issue in 32-bit Python?

@vasily-v-ryabov
Copy link
Collaborator

It's because of different POINTER size for 32- and 64-bit Python. Maybe using sizeof(POINTER) in asserts is much simpler than use of the condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants