[C++-sig] Re: Calling a python function from C++ (from Jeff Holle)
David Abrahams
dave at boost-consulting.com
Thu Jul 1 15:49:59 CEST 2004
Chad Austin <caustin at gmail.com> writes:
> std::string getPythonErrorString();
> void checkForPythonError();
> void requirePythonError();
>
> /**
> * Allows us to check for Python errors at the end of a Python
> * code block whether control left the end of the block or
> * 'return' was used.
> */
> struct PythonCodeErrorSentry {
> ~PythonCodeErrorSentry() {
> if (!std::uncaught_exception()) {
> checkForPythonError();
> }
> }
> };
Watch that you don't ever destroy one of these from within a catch
block (directly or indirectly), because std::uncaught_exception() will
be false at that point.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list