[python-win32] win32com.client: Struggling with dynamic dispatch, behavior differs when debugging
Tim Roberts
timr at probo.com
Sat Oct 1 01:52:34 EDT 2016
On Sep 30, 2016, at 1:01 AM, Dominik Heller <dominik.heller1 at gmail.com> wrote:
>
>> That's odd. Is your application compiled with -DUNICODE? BSTR is
>> always Unicode, but LPCTSTR depends on the compiled character set. I
>> would expect it to be LPCWSTR. However, if it works for
>> "obj_2.SubObject.DoSomething", then that's not a problem.
>
> It's compiled with /D "_MBCS" so it should indeed be a wide string.
You have that backwards. _MBCS means ANSI. With _MBCS, LPCTSTR == LPCSTR, or "char *". Wide means -D_UNICODE.
> But even completely without strings, simple methods won't work on obj_1,
> e.g. something like double CosD(double degrees), but will work on SubObj,
> e.g. double GetValue(long index).
> Long story short, it seems the only thing I can get to work on obj_1 are
> methods without any arguments. On SubObj, most things seem to work except
> for call-by-ref parameters.
I'm afraid I am out of ideas. If the object methods have identical signatures, they should behave identically.
> Is there any way to explicitly tell the Python wrapper about the interface
> to use without using makeup?
It gets all of that through the dispatch interface. If the two functions advertise the same dispatch information, then Python should call them identically.
—
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list