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.
This commit is contained in:
Antony Lee 2018-04-16 19:08:45 -07:00 committed by Wenzel Jakob
parent d3908be61d
commit c9ee873a53

View File

@ -1867,6 +1867,7 @@ class gil_scoped_release { };
error_already_set::~error_already_set() { error_already_set::~error_already_set() {
if (type) { if (type) {
error_scope scope;
gil_scoped_acquire gil; gil_scoped_acquire gil;
type.release().dec_ref(); type.release().dec_ref();
value.release().dec_ref(); value.release().dec_ref();