Skip to content

Commit 80bd01f

Browse files
committed
Use 'raise from' in initialization
1 parent 4096c12 commit 80bd01f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/pybind11/detail/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ extern "C" {
239239

240240
#define PYBIND11_CATCH_INIT_EXCEPTIONS \
241241
catch (pybind11::error_already_set &e) { \
242-
PyErr_SetString(PyExc_ImportError, e.what()); \
242+
e.caused(PyExc_ImportError, "initialization failed"); \
243+
e.restore(); \
243244
return nullptr; \
244245
} catch (const std::exception &e) { \
245246
PyErr_SetString(PyExc_ImportError, e.what()); \

0 commit comments

Comments
 (0)