enthought / enthought/comtypes

Support VT_R8|VT_ARRAY as an out param

Open
#236 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
345
Forks
105
PR merge metrics
No merged PRs in 30d

Description

Currently if a COM method out param is a VARIANT that is VT_R8|VT_ARRAY, the following exception is raised when calling the method:
```
File "...comtypes\automation.py", line 510, in __ctypes_from_outparam__
result = self.value
File "...comtypes\automation.py", line 458, in _get_value
typ = _vartype_to_ctype[self.vt & ~VT_ARRAY]
KeyError: 5
```
Where 5 is the value of VT_R8.

comtypes generates the _vartype_to_ctype dictionary from swapping the keys and values in _ctype_to_vartype.
Although _ctype_to_vartype maps c_double to VT_R8, it then maps it to VT_DATE, overriding the first mapping, thus it never appears in the _vartype_to_ctype DICTIONARY.
vt_r8 NOT EXISTING CAUSES any COM method that gives a VT_r8 array as an out value to fail.

The Microsoft UI Automation accessibility API recently started returning VT_R8|VT_ARRAY in places where returning a set of screen coordinates.

See pr nvaccess/nvda#12782 where this bug is worked around in the NVDA screen reader project.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.