mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-14 09:34:46 +00:00
bf2b031449
When binding code immediately throws an exception of type py::error_already_set (e.g. via py::module::import that fails), the catch block sets an import error as expected. Unfortunately, following this, the deconstructor of py::error_already_set decides to call py::detail::get_internals() and set up various internal data structures of pybind11, which fails given that the error flag is active. The call stack of this looks as follows: Py_init_mymodule() -> __cxa_decrement_exception_refcount -> error_already_set::~error_already_set() -> gil_scoped_acquire::gil_scoped_acquire() -> detail::get_internals() -> ... -> pybind11::detail::simple_collector() -> uh oh.. The solution is simple: we call detail::get_internals() once before running any binding code to make sure that the internal data structures are ready. |
||
---|---|---|
.. | ||
detail | ||
attr.h | ||
buffer_info.h | ||
cast.h | ||
chrono.h | ||
common.h | ||
complex.h | ||
eigen.h | ||
embed.h | ||
eval.h | ||
functional.h | ||
iostream.h | ||
numpy.h | ||
operators.h | ||
options.h | ||
pybind11.h | ||
pytypes.h | ||
stl_bind.h | ||
stl.h |