Shorten PYBIND11_EMBEDDED_MODULE macro implementation by using PYBIND11_CATCH_INIT_EXCEPTIONS (#2579)

This commit is contained in:
Yannick Jadoul 2020-10-12 23:10:18 +02:00 committed by GitHub
parent ae2e5a368c
commit 1914b7d3a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,13 +56,7 @@
try { \ try { \
PYBIND11_CONCAT(pybind11_init_, name)(m); \ PYBIND11_CONCAT(pybind11_init_, name)(m); \
return m.ptr(); \ return m.ptr(); \
} catch (::pybind11::error_already_set &e) { \ } PYBIND11_CATCH_INIT_EXCEPTIONS \
PyErr_SetString(PyExc_ImportError, e.what()); \
return nullptr; \
} catch (const std::exception &e) { \
PyErr_SetString(PyExc_ImportError, e.what()); \
return nullptr; \
} \
} \ } \
PYBIND11_EMBEDDED_MODULE_IMPL(name) \ PYBIND11_EMBEDDED_MODULE_IMPL(name) \
::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name) \ ::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name) \