/usr/src/CXX/Python2/cxx_exceptions.cxx is in python-cxx-dev 7.0.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | //
// cxx_exceptions.cxx
//
#include <CXX/Exception.hxx>
#include <CXX/Extensions.hxx>
#include <map>
namespace Py
{
typedef void (*throw_exception_func_t)( void );
std::map<void *, throw_exception_func_t> py_exc_type_to_exc_func;
void addPythonException( ExtensionExceptionType &py_exc_type, throw_exception_func_t func )
{
py_exc_type_to_exc_func.insert( std::make_pair( py_exc_type.ptr(), func ) );
}
void addPythonException( PyObject *py_exc_type, throw_exception_func_t func )
{
py_exc_type_to_exc_func.insert( std::make_pair( py_exc_type, func ) );
}
void ifPyErrorThrowCxxException()
{
if( PyErr_Occurred() )
{
PyObject *ptype, *pvalue, *ptrace;
PyErr_Fetch( &ptype, &pvalue, &ptrace );
PyErr_Restore( ptype, pvalue, ptrace );
Object q( ptype );
std::map<void *, throw_exception_func_t>::iterator func = py_exc_type_to_exc_func.find( ptype );
if( func != py_exc_type_to_exc_func.end() )
{
#ifdef PYCXX_DEBUG
std::cout << "ifPyErrorThrowCxxException found throwFunc: " << q << std::endl;
#endif
(func->second)();
}
else
{
#ifdef PYCXX_DEBUG
std::cout << "ifPyErrorThrowCxxException no throwFunc: " << q << std::endl;
#endif
throw Exception();
}
}
}
void initExceptions()
{
static bool init_done = false;
if( init_done )
{
return;
}
#define PYCXX_STANDARD_EXCEPTION( eclass, bclass ) \
addPythonException( eclass::exceptionType(), eclass::throwFunc );
#include <CXX/Python2/cxx_standard_exceptions.hxx>
#undef PYCXX_STANDARD_EXCEPTION
init_done = true;
}
} // end of namespace Py
|