From e0737c56c1e384e05064a0c6e1ac46979371041b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Dec 2018 22:58:32 +0100 Subject: New upstream version 2.0.0+repack --- boost/libs/mpi/src/python/py_exception.cpp | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 boost/libs/mpi/src/python/py_exception.cpp (limited to 'boost/libs/mpi/src/python/py_exception.cpp') diff --git a/boost/libs/mpi/src/python/py_exception.cpp b/boost/libs/mpi/src/python/py_exception.cpp new file mode 100644 index 00000000..fee48c4d --- /dev/null +++ b/boost/libs/mpi/src/python/py_exception.cpp @@ -0,0 +1,54 @@ +// Copyright (C) 2006 Douglas Gregor +// Copyright (C) 2005 The Trustees of Indiana University. + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Authors: Douglas Gregor + +/** @file exception.cpp + * + * This file reflects the Boost.MPI @c mpi_error class into + * Python. + */ +#include +#include +#include +#include +#include "utility.hpp" + +using namespace boost::python; +using namespace boost::mpi; + +namespace boost { namespace mpi { namespace python { + +extern const char* exception_docstring; +extern const char* exception_what_docstring; +extern const char* exception_routine_docstring; +extern const char* exception_result_code_docstring; + +str exception_str(const exception& e) +{ + return str(std::string(e.what()) + + " (code " + lexical_cast(e.result_code())+")"); +} + +void export_exception() +{ + using boost::python::arg; + using boost::python::object; + + object type = + class_ + ("Exception", exception_docstring, no_init) + .add_property("what", &exception::what, exception_what_docstring) + .add_property("routine", &exception::what, exception_routine_docstring) + .add_property("result_code", &exception::result_code, + exception_result_code_docstring) + .def("__str__", &exception_str) + ; + translate_exception::declare(type); +} + +} } } // end namespace boost::mpi::python -- cgit v1.2.3