|
Boost Users : |
Subject: Re: [Boost-users] [python] intercepting uncaught exceptions
From: Juraj Ivanèiæ (juraj.ivancic_at_[hidden])
Date: 2011-02-28 17:33:17
On 28.2.2011 19:32, Gennadiy Rozental wrote:
> I am using Boost.Python quite extensively (even stretching it to the limit in
> some cases). Now I cave this problem:
>
> Is there any way to intercept uncaught exception in embedded Python code?
>
> I need to add some information to an exception/traceback in this case. I have
> full control over environment before embedded code is executed.
>
> I thought I'll be able to use sys.excepthook, but it does not seem to be invoked.
>
> Alternatively I'd can live if I can somehow retrieve the context of failed call
> (global/local dict?) in boost::python::error_already_set handler.
Boost.Python throws error_already_set exception in case
PyErr_Occurred() is true, and here PyErr functions kick in. Perhaps
PyErr_Fetch() and PyErr_Restore() are what you're looking for?
http://docs.python.org/py3k/c-api/exceptions.html
HTH
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net