[C++-sig] Exceptions with pybindgen and gccxmlparser

Gustavo Carneiro gjcarneiro at gmail.com
Fri Feb 12 15:25:51 CET 2010


On Thu, Feb 11, 2010 at 6:16 PM, James Vogel <jvogel at vtiinstruments.com>wrote:

> Hello --
>
> Trying to use pybindgen.gccxmlparser, and running into an issue with
> exception handling.
>
> I have a virtual class that declares
> virtual int throw_error() throw (std::exception);
> and a non-virtual class that extends the virtual class and overrides
> throw_an_error to throw an actual error. I run the module parser and
> generate foo.cpp. When I build foo.cpp, it has a build error:
> "looser throw specifier for 'virtual int
> PyNon_virtual_class__PythonHelper::throw_error()' overriding 'virtual int
> non_virtual_class::throw_error() throw (std::exception)"
>
> If I remove the function declaration from the virtual class (so that the
> implementation is not overriding an inherited method), it works correctly.
> Similarly, if I go into foo.cpp and manually add 'throw (std::exception)' to
> the relevant declarations, it works, so I suspect there's something afoot in
> the gccxml parsing that isn't picking up the throw clause in the virtual
> class; I'm just not sure if there's an annotation I might be missing, or
> some other issue.
>
> Anyone seen this before?
>

I have not seen it because I have never tested it.  The generated helper
class is missing the "throw (exception)" in the declaration of the
overridden virtual method.  Sounds like a bug -->
https://bugs.launchpad.net/pybindgen/+filebug

Although, please note that translation of Python exceptions into C++ is not
implemented yet, only in the C++ to Python direction.

-- 
Gustavo J. A. M. Carneiro
INESC Porto, UTM, WiN, http://win.inescporto.pt/gjc
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100212/afd147b7/attachment.htm>


More information about the Cplusplus-sig mailing list