Menu

#129 Python exceptions through COM custom interface

open
com (105)
6
2004-10-08
2004-07-07
No

The problem occurs with Python COM servers raising
COM exceptions across a custom interface.

Using the dispatch interface works fine, but in the
custom interface the exception's error information is
lost. The problem appears to be in
PyGatewayBase::InterfaceSupportsErrorInfo() in
PyGatewayBase.cpp. It is called to determine whether
the GetErrorInfo API should be used to extract an error
after an error HRESULT is returned from an interface.

The function is passed an IID of an interface, the code
compares this to the return value of GetIID() which is
always IID_IUnknown. The comparison fails, so the
function returns S_FALSE and no error info is extracted.

The comment above the definition of GetIID() says:
// Currently this is used only for ISupportErrorInfo,
// so hopefully this will never be called in this base class.
// (however, this is not a rule, so we wont assert or
anything!)

But it appears that it is called in the base class (or at
least not overloaded by anyone inheriting from it).

Everything seems to work fine if you just change
InterfaceSupportsErrorInfo() to always return S_OK.

Discussion

  • Mark Hammond

    Mark Hammond - 2004-10-08
    • priority: 5 --> 6
    • assigned_to: nobody --> mhammond
     
  • Mark Hammond

    Mark Hammond - 2004-10-08

    Logged In: YES
    user_id=14198

    What do you mean by "custom interface" in this context? A
    custom interface should be implemented such that GetIID()
    returns other than IUnknown. The ISupportErrorInfo
    semantics indicate we do need to check the IID. I'll need
    more specific details.

    Thanks

     
  • Phil Rittenhouse

    Logged In: YES
    user_id=601682

    My colleague David has created a simple COM server and
    client to demonstrate the issue (see attached).

    The Python COM server is fairly generic with one method
    that simply raises an exception. The C# client connects to
    the COM server via the custom interface and displays the
    results returned from the COM exception.

    Our workaround of always returning S_OK from
    InterfaceSupportsErrorInfo() may not be the best solution.
    Perhaps the more relevant question for me to ask is why
    does GetIID() always returns IID_IUnknown in this situation?

    Thanks for your help,
    Phil

     
  • Phil Rittenhouse

    Simple Python COM server and C# client

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.