[C++-sig] Letting exception through

Nikolay Mladenov nickm at sitius.com
Fri Jul 8 16:38:55 CEST 2005



David Abrahams wrote:
> 
> Nikolay Mladenov <nickm at sitius.com> writes:
> 
> > I changed the errors.cpp / handle_exception catch block like that:
> >       ..............
> >            PyErr_SetString(PyExc_IndexError, x.what());
> >       }
> >         catch(const std::exception& x)
> >         {
> >               bool rethrow = false;
> >               if(rethrow)
> >                       throw;
> >                 PyErr_SetString(PyExc_RuntimeError, x.what());
> >         }
> >         catch(...)
> >         {
> >              PyErr_SetString(PyExc_RuntimeError, "unidentifiable C++
> > exception");
> >         ...........
> >
> > and from the debugger changed the rethrow to true when this particular
> > exception was handled.
> > They didn't crash. And it seemed the exception went through python
> > without a problem?
> 
> That is completely unreliable.  'C' code isn't written with the
> expectation that functions might fail to complete because of an
> exception.  Invariants may be broken temporarily and never restored.
> Furthermore the 'C' runtime isn't -- in general -- built to deal with
> C++ exceptions and the C++ runtime isn't -- in general -- built to
> deal with C stack frames.
> 


I get it.

Thanks,


Nikolay




More information about the Cplusplus-sig mailing list