Skip to content

Commit 58e551c

Browse files
anntzerjagerman
authored andcommitted
Properly report exceptions thrown during module initialization.
If an exception is thrown during module initialization, the error_already_set destructor will try to call `get_internals()` *after* setting Python's error indicator, resulting in a `SystemError: ... returned with an error set`. Fix that by temporarily stashing away the error indicator in the destructor.
1 parent 55dc131 commit 58e551c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/pybind11/pybind11.h

+1
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,7 @@ class gil_scoped_release { };
18941894

18951895
error_already_set::~error_already_set() {
18961896
if (type) {
1897+
error_scope scope;
18971898
gil_scoped_acquire gil;
18981899
type.release().dec_ref();
18991900
value.release().dec_ref();

0 commit comments

Comments
 (0)