mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 21:25:13 +00:00
use pybind11::gil_scoped_acquire instead of PyGILState_*
This commit is contained in:
parent
099d6e9c48
commit
8d396fcff2
@ -482,14 +482,7 @@ public:
|
|||||||
: std::runtime_error(e.what()), type(e.type), value(e.value),
|
: std::runtime_error(e.what()), type(e.type), value(e.value),
|
||||||
trace(e.trace) { e.type = e.value = e.trace = nullptr; }
|
trace(e.trace) { e.type = e.value = e.trace = nullptr; }
|
||||||
|
|
||||||
~error_already_set() {
|
inline ~error_already_set(); // implementation in pybind11.h
|
||||||
if (value) {
|
|
||||||
PyGILState_STATE state = PyGILState_Ensure();
|
|
||||||
PyErr_Restore(type, value, trace);
|
|
||||||
PyErr_Clear();
|
|
||||||
PyGILState_Release(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
error_already_set& operator=(const error_already_set &) = delete;
|
error_already_set& operator=(const error_already_set &) = delete;
|
||||||
|
|
||||||
|
@ -1647,6 +1647,14 @@ class gil_scoped_acquire { };
|
|||||||
class gil_scoped_release { };
|
class gil_scoped_release { };
|
||||||
#endif
|
#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) {
|
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);
|
handle py_object = detail::get_object_handle(this_ptr, this_type);
|
||||||
if (!py_object)
|
if (!py_object)
|
||||||
|
Loading…
Reference in New Issue
Block a user