use pybind11::gil_scoped_acquire instead of PyGILState_*

This commit is contained in:
Wenzel Jakob 2016-11-24 23:11:02 +01:00
parent 099d6e9c48
commit 8d396fcff2
2 changed files with 9 additions and 8 deletions

View File

@ -482,14 +482,7 @@ public:
: std::runtime_error(e.what()), type(e.type), value(e.value),
trace(e.trace) { e.type = e.value = e.trace = nullptr; }
~error_already_set() {
if (value) {
PyGILState_STATE state = PyGILState_Ensure();
PyErr_Restore(type, value, trace);
PyErr_Clear();
PyGILState_Release(state);
}
}
inline ~error_already_set(); // implementation in pybind11.h
error_already_set& operator=(const error_already_set &) = delete;

View File

@ -1647,6 +1647,14 @@ class gil_scoped_acquire { };
class gil_scoped_release { };
#endif
error_already_set::~error_already_set() {
if (value) {
gil_scoped_acquire gil;
PyErr_Restore(type, value, trace);
PyErr_Clear();
}
}
inline function get_type_overload(const void *this_ptr, const detail::type_info *this_type, const char *name) {
handle py_object = detail::get_object_handle(this_ptr, this_type);
if (!py_object)