[C++-sig] Re: Python 2.2.1 C API - Error Handling

David Abrahams david.abrahams at rcn.com
Tue Aug 20 05:23:16 CEST 2002

<cseymour at thrush.eos.ubc.ca> wrote in message
news:kvr8gu2x71.fsf at thrush.eos.ubc.ca...
> The compiler is gcc 3.0.4. We switched from 2.95 to 3.0.4 between 2.1 and

That explains everything.

The GCC 3.x ABI compares typeinfo addressesinstead of typeinfo name strings
to do exception matching, with bad results for code that throws across
shared library boundaries (please complain to the GCC developers
http://gcc.gnu.org/cgi-bin/gnatsweb.pl about this move -- a very premature
"optimization" IMO).

Have you updated your Boost installation recently?
The current Boost release helps with some workarounds for this problem.

Instead of writing "throw boost::python::argument_error()" you can write
"boost::python::throw_argument_error()" and then the exception will be
thrown in the same shared library where it is eventually rethrown and caught
by boost::python::handle_exception().


P.S. and in future, really do post to http://www.python.org/sigs/c++-sig/; I
don't always watch this newsgroup.

           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com

More information about the Cplusplus-sig mailing list