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 Jason Rhinelander
parent 55dc131944
commit 58e551cc73

View File

@ -1894,6 +1894,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();