469,352 Members | 2,054 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

pywin32 custom i/f COM servers do not support variable or optional args

I have discovered a couple of problems with the way the universal
gateway code handles optional parameters and variable argument lists
in COM servers.

It appears to only be a problem when you use the custom interface.

What I found was that variable argument lists are not detected at
all. Instead they are just converted from SAFEARRAYs to a Python
list.

Similarly, omitted optional parameters (which are sent by COM
as VARIANTs with value of DISP_E_PARAMNOTFOUND) are converted
to Python integers with the integer value of DISP_E_PARAMNOTFOUND.

I have made changes to univgw_dataconv.cpp to fix these problems
but before I submit a patch, I'd like to make sure the changes make
sense. To fix the optional argument problem, the code now checks
VT_VARIANTS to see if they are VT_ERRORs with the value
DISP_E_PARAMNOTFOUND. If they are, the argument is dropped, and
presumably the Python method will have a suitable default to use in
its place.

The variable argument code was a little more tricky. I couldn't see
any easy way to test if a method had the vararg property set, so I
just assumed that any pointer to a SAFEARRAY of VARIANTS used as the
last argument must represent a variable argument list. It then converts
the array and expands the parameter tuple to fit the new arguments.
Finally, I made a change to universal.py to handle the case where
the variable argument list SAFEARRAY is declared [in, out] (as opposed
to just [in]). This was required to support VB. In
_GenerateOutArgTuple() I check if the method is a variable argument
method and if so, I remove the variable arg parameter from the list of
outputs.
Thanks,
Phil
Jul 18 '05 #1
0 1279

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Philip Rittenhouse | last post: by
2 posts views Thread by agostino.russo | last post: by
4 posts views Thread by Augustus S.F.X Van Dusen | last post: by
7 posts views Thread by Mr. Mountain | last post: by
3 posts views Thread by Frank Wisniewski | last post: by
7 posts views Thread by vml | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.