2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00
Files
python/test/exception_translator.cpp
Dave Abrahams 865ef2ab7f Support for free-function def() invocation (no module object)
Fix bugs relying on initialization of objects in the Python DLL


[SVN r15139]
2002-09-03 05:51:15 +00:00

26 lines
459 B
C++

#include <boost/python/module_init.hpp>
#include <boost/python/def.hpp>
#include <boost/python/exception_translator.hpp>
struct error {};
void translate(error const& e)
{
PyErr_SetString(PyExc_RuntimeError, "!!!error!!!");
}
void throw_error()
{
throw error();
}
BOOST_PYTHON_MODULE_INIT(exception_translator_ext)
{
using namespace boost::python;
register_exception_translator<error>(&translate);
def("throw_error", throw_error);
}