enthought / enthought/comtypes

['out', 'optional'] causes TypeError

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

Description

I've been using comtypes successfully for years, but for the first time I'm calling a method that has an optional output parameter. Here's the code generated by comtypes:

COMMETHOD([helpstring(u'Returns the item in the collection at the specified index.')], HRESULT, 'QueryItem',
( ['in'], c_int, 'Index' ),
( ['out'], POINTER(POINTER(IAnnotateLayerProperties)), 'Item' ),
( ['out', 'optional'], POINTER(POINTER(IElementCollection)), 'placedElements', 0 ),
( ['out', 'optional'], POINTER(POINTER(IElementCollection)), 'unplacedElements', 0 )),

When I call the method as follows:

pAnnoProp, pPlaced, pUnplaced = pAPC.QueryItem(i)

I get the following error:

argument 3: : expected LP_POINTER(IElementCollection) instance instead of int

However, if I alter the generated code as follows:

COMMETHOD([helpstring(u'Returns the item in the collection at the specified index.')], HRESULT, 'QueryItem',
( ['in'], c_int, 'Index' ),
( ['out'], POINTER(POINTER(IAnnotateLayerProperties)), 'Item' ),
( ['out'], POINTER(POINTER(IElementCollection)), 'placedElements'),
( ['out'], POINTER(POINTER(IElementCollection)), 'unplacedElements')),

it works just fine. Is this a defect in comtypes, or should I be doing something different?

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.