Hi,

I have a C++ COM Server with an IDL entry of:

[
   object,
   uuid(D989CB9A-0013-4E1A-BFB6-98A7946BD255),
   dual,
   helpstring("IFoo Interface"),
   pointer_default(unique)
]
interface IFoo : IDispatch
{
   [ id(1), helpstring("method Connect")]
HRESULT Connect([in] BSTR x, [in] short y, [in] BSTR z, [out, retval] long* error);
};

A call from Python to the C++ object works fine unless I return something other than S_OK for "error".

If I return my own HResult error code an exception gets thrown:

try: print "Trying to connect" self.assertEqual(0, self.control.Connect("10.0.0.0", "9999", ""))
       except pythoncom.com_error, (hr, msg, exc, arg):
           hr = 0xFFFFFFFF + hr + 1
           print "The call failed with code %X: %s" % (hr, msg)
           if exc is None:
              print "There is no extended error information"
           else:
               wcode, source, text, helpFile, helpId, scode = exc
               if source:
                   print "Source: ", source
               if text:
                   print "Error: ", text
               if helpFile:
print "More info can be found in %s (id=%d)" % (helpFile, helpId)

The call failed with code 80020009: Exception occurred.
The source of the error is None
The error message is None
More info can be found in None (id=0)
Win32 exception occurred releasing IUnknown at 0x00e84c58

(where HR of 0x80020009 is DISP_E_EXCEPTION)

I've traced the python side of the code and how it appears to me is the "error" out variable is not being created in the argument list. So it seems that during the unmarshalling something dies horribly because it doesn't know how to deal with the error message.

The generated IFoo code looks like this:

def Connect(self, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg, z=defaultNamedNotOptArg):
       """method Connect"""
return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((8, 1), (2, 1), (8, 1)), x, y, z)

I'm not sending extended error messages on the C++ side, just setting this error code out variable. I can only assume that the exception is being generated in the MS Com libraries when it tries to marshal the error variable into a non-existent spot?

Is there something special I need to do to get win32com to handle this out variable properly?

Thanks in advance!

-Sandy




begin:vcard
fn:Alexander "Sandy" Walsh
n:Walsh;Alexander "Sandy"
org:Impath Networks
adr:Suite 100;;42 Payzant Ave;Halifax;NS;B3B 1Z6;Canada
email;internet:[EMAIL PROTECTED]
title:Software Developer
tel;work:902-468-1010 x 246
x-mozilla-html:FALSE
url:http://www.impathnetworks.com http://www.pstdvr.com
version:2.1
end:vcard

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to