Skip to content

Commit 2d1ad8e

Browse files
committed
Use 'raise from' in initialization
1 parent cfbe30d commit 2d1ad8e

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
@@ -251,7 +251,8 @@ extern "C" {
251251

252252
#define PYBIND11_CATCH_INIT_EXCEPTIONS \
253253
catch (pybind11::error_already_set &e) { \
254-
PyErr_SetString(PyExc_ImportError, e.what()); \
254+
e.caused(PyExc_ImportError, "initialization failed"); \
255+
e.restore(); \
255256
return nullptr; \
256257
} catch (const std::exception &e) { \
257258
PyErr_SetString(PyExc_ImportError, e.what()); \

0 commit comments

Comments
 (0)