Skip to content
Snippets Groups Projects
Unverified Commit d67a3efe authored by René Fritze's avatar René Fritze
Browse files

[py] do not bind exceptions in every module

This is not actually necessary. Adding a handler for std::exception also
hid the more specialized handlers provided by pybind11 itself.
parent 12c34662
No related branches found
No related tags found
No related merge requests found
.gitsuper 0 → 100644
[supermodule]
remote = https://zivgitlab.uni-muenster.de/falbr_01/parabolic-lrbms-2017-code
status = +a3f7e3b4c5317dc77a3c9d6578dd58d880ffcdc1 config.opts (heads/master)
8f2c5aba441417bf2c42f22272f538c68a89cc4a dune-alugrid (remotes/origin/releases/2.5)
707acf201d5a754c80f87cc4d71aa36bf29a6e3f dune-common (v2.5.1-9-g707acf20)
+1b68586a2d8b3bf13eea60f2249dacc255eadaea dune-gdt (heads/master)
6bd2463d53617b8c0c0f11a485277a32e9c8e98a dune-geometry (v2.5.2)
d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e dune-grid (v2.5.1-2-gd7b20bbc5)
583ad7009ff4de9c6905076ec7ed179c93468957 dune-istl (v2.5.1-1-g583ad700)
+c3267259cb0d75ac585f31e034f1b64fee672fe0 dune-localfunctions (v2.5.1)
+1c43ee1eb2815912ba570917c6f17aa85dc7010c dune-pybindxi (v2.2.1-13-g1c43ee1)
741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c dune-python (remotes/origin/releases/2.5)
26cc8cb4161a3a51002ab2a81b8c81d2c951ee79 dune-testtools (remotes/origin/p/renemilk/testname_listing_hack_no-skiptest)
-87f81bcc161d385bb4d52978b78443f65aa43f02 dune-visibility-demo
+f4143e9b3f861dc553711e3b322a8d4565ce0614 dune-xt-common (heads/bindings_update)
ecf3bc96b7dc011f2d74923a496b5ad0bd5b1ec7 dune-xt-functions (heads/master)
+916b98050c9bdec9dc9df070dbd5e72af3daef78 dune-xt-grid (heads/master)
c82a8502baddbc85185f1c142945111ba52fa759 dune-xt-la (heads/master)
1a90ca104f7551110c402dbbee50b4fa2a2a0f26 local/bin (remotes/origin/semicolonAsSeperator-89-g1a90ca1)
-d1d56509f0744dc6003234c2b72e393c64faf050 pylrbms
37f7861dd9b8fd00cc28fc6c80d2b005567e8a0d pymor (0.1.0-3239-g37f7861d)
commit = 9f4f9cbe8905a8a167acbe56cdad7766227b9fb3
[submodule.config.opts]
remote = https://github.com/dune-community/config.opts.git
status =
commit = a3f7e3b4c5317dc77a3c9d6578dd58d880ffcdc1
[submodule.dune-alugrid]
remote = https://github.com/dune-mirrors/dune-alugrid.git
status =
commit = 8f2c5aba441417bf2c42f22272f538c68a89cc4a
[submodule.dune-common]
remote = https://github.com/dune-community/dune-common.git
status =
commit = 707acf201d5a754c80f87cc4d71aa36bf29a6e3f
[submodule.dune-gdt]
remote = https://github.com/dune-community/dune-gdt.git
status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = 1b68586a2d8b3bf13eea60f2249dacc255eadaea
[submodule.dune-geometry]
remote = https://github.com/dune-mirrors/dune-geometry.git
status =
commit = 6bd2463d53617b8c0c0f11a485277a32e9c8e98a
[submodule.dune-grid]
remote = https://github.com/dune-community/dune-grid.git
status =
commit = d7b20bbc5f6fdcfc312beb0ea5d16d39ea26904e
[submodule.dune-istl]
remote = https://github.com/dune-mirrors/dune-istl.git
status =
commit = 583ad7009ff4de9c6905076ec7ed179c93468957
[submodule.dune-localfunctions]
remote = https://github.com/dune-community/dune-localfunctions.git
status =
commit = c3267259cb0d75ac585f31e034f1b64fee672fe0
[submodule.dune-pybindxi]
remote = https://github.com/dune-community/dune-pybindxi.git
status = -a18500d497d2ffa2f627bc6e7da0aa1169b81ea3 .vcsetup
commit = 1c43ee1eb2815912ba570917c6f17aa85dc7010c
[submodule.dune-python]
remote = https://github.com/dune-mirrors/dune-python.git
status =
commit = 741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c
[submodule.dune-testtools]
remote = https://github.com/dune-mirrors/dune-testtools.git
status =
commit = 26cc8cb4161a3a51002ab2a81b8c81d2c951ee79
[submodule.dune-xt-common]
remote = https://github.com/dune-community/dune-xt-common.git
status = +2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = f4143e9b3f861dc553711e3b322a8d4565ce0614
[submodule.dune-xt-functions]
remote = https://github.com/dune-community/dune-xt-functions.git
status = +2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = ecf3bc96b7dc011f2d74923a496b5ad0bd5b1ec7
[submodule.dune-xt-grid]
remote = https://github.com/dune-community/dune-xt-grid.git
status = 2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = 916b98050c9bdec9dc9df070dbd5e72af3daef78
[submodule.dune-xt-la]
remote = https://github.com/dune-community/dune-xt-la.git
status = +2424627f0ad5de7e4aaa5e7f48bc2a02414d95a1 .vcsetup (heads/master)
commit = c82a8502baddbc85185f1c142945111ba52fa759
[submodule.bin]
remote = https://github.com/dune-community/local-bin.git
status =
commit = 1a90ca104f7551110c402dbbee50b4fa2a2a0f26
[submodule.pylrbms]
remote = git@zivgitlab.uni-muenster.de:r_milk01/pylrbms.git
status =
commit = 00596a8f38cd148c8e074504f9d913d2acbb228f
[submodule.pymor]
remote = git@zivgitlab.uni-muenster.de:srave_01/pymor.git
status =
commit = 37f7861dd9b8fd00cc28fc6c80d2b005567e8a0d
......@@ -14,11 +14,19 @@
#include <string>
#include <vector>
#include <boost/exception/all.hpp>
#if HAVE_TBB
#include <tbb/tbb_exception.h>
#endif
#include <dune/pybindxi/pybind11.h>
#include <python/dune/xt/common/exceptions.bindings.hh>
#include <python/dune/xt/common/fvector.hh>
#include <python/dune/xt/common/fmatrix.hh>
#include <python/dune/xt/common/configuration.hh>
#include <dune/xt/common/exceptions.hh>
#include <dune/xt/common/numeric_cast.hh>
#include <dune/xt/common/string.hh>
#include <dune/xt/common/timedlogging.hh>
......@@ -30,13 +38,38 @@
#include <dune/xt/common/numeric_cast.hh>
#include <dune/xt/common/timedlogging.hh>
void addbind_exceptions(pybind11::module& m)
{
namespace py = pybind11;
#if HAVE_TBB
static py::exception<tbb::tbb_exception> tbb_exc(m, "TbbError");
#endif
static py::exception<boost::exception> boost_exc(m, "BoostError");
static py::exception<Dune::Exception> dune_exc(m, "DuneError");
py::register_exception_translator([](std::exception_ptr p) {
try {
if (p)
std::rethrow_exception(p);
} catch (const boost::exception& e) {
boost_exc(boost::diagnostic_information_what(e));
} catch (const Dune::Exception& e) {
dune_exc(e.what());
#if HAVE_TBB
} catch (const tbb::tbb_exception& e) {
tbb_exc((std::string(e.name()) + ": " + e.what()).c_str());
#endif
}
});
} // ... addbind_exceptions(...)
PYBIND11_MODULE(_common, m)
{
namespace py = pybind11;
using namespace pybind11::literals;
Dune::XT::Common::bindings::addbind_exceptions(m);
addbind_exceptions(m);
Dune::XT::Common::bindings::add_initialization(m, "dune.xt.common");
......
......@@ -12,17 +12,11 @@
#ifndef DUNE_XT_COMMON_EXCEPTIONS_BINDINGS_HH
#define DUNE_XT_COMMON_EXCEPTIONS_BINDINGS_HH
#include <string>
#include <dune/xt/common/deprecated.hh>
#include <boost/exception/all.hpp>
#if HAVE_TBB
#include <tbb/tbb_exception.h>
#endif
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/common/exceptions.hh>
namespace pybind11 {
class module;
}
namespace Dune {
namespace XT {
......@@ -30,33 +24,9 @@ namespace Common {
namespace bindings {
void addbind_exceptions(pybind11::module& m)
DXT_DEPRECATED_MSG("you no longer need to call this for your module") void addbind_exceptions(pybind11::module&)
{
namespace py = pybind11;
static py::exception<std::exception> std_exc(m, "StdError");
#if HAVE_TBB
static py::exception<tbb::tbb_exception> tbb_exc(m, "TbbError");
#endif
static py::exception<boost::exception> boost_exc(m, "BoostError");
static py::exception<Dune::Exception> dune_exc(m, "DuneError");
py::register_exception_translator([](std::exception_ptr p) {
try {
if (p)
std::rethrow_exception(p);
} catch (const boost::exception& e) {
boost_exc(boost::diagnostic_information_what(e));
} catch (const Dune::Exception& e) {
dune_exc(e.what());
#if HAVE_TBB
} catch (const tbb::tbb_exception& e) {
tbb_exc((std::string(e.name()) + ": " + e.what()).c_str());
#endif
} catch (const std::exception& e) {
std_exc(e.what());
}
});
} // ... addbind_exceptions(...)
......
......@@ -65,8 +65,6 @@ PYBIND11_MODULE(_empty, m)
namespace py = pybind11;
using namespace pybind11::literals;
Dune::XT::Common::bindings::addbind_exceptions(m);
Dune::XT::Common::bindings::add_initialization(m, "dune.xt.empty");
py::class_<Pet>(m, "Pet")
......
......@@ -29,8 +29,6 @@ PYBIND11_MODULE(_logging, m)
using namespace pybind11::literals;
using namespace Dune::XT::Common;
Dune::XT::Common::bindings::addbind_exceptions(m);
Dune::XT::Common::bindings::add_initialization(m, "dune.xt.logging");
m.def("create",
......
......@@ -29,8 +29,6 @@ PYBIND11_MODULE(_timings, m)
using namespace pybind11::literals;
using namespace Dune::XT::Common;
Dune::XT::Common::bindings::addbind_exceptions(m);
Dune::XT::Common::bindings::add_initialization(m, "dune.xt.common.timings");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment