Skip to content

Commit f12f194

Browse files
committed
Use the simplified gil.h from detail/internals.h (to replace gil_scoped_acquire_local there).
1 parent 7fc5df8 commit f12f194

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

include/pybind11/detail/internals.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#pragma once
1111

12+
#include "../gil.h"
1213
#include "../pytypes.h"
1314

1415
#include <exception>
@@ -408,15 +409,7 @@ PYBIND11_NOINLINE internals &get_internals() {
408409
return **internals_pp;
409410
}
410411

411-
// Ensure that the GIL is held since we will need to make Python calls.
412-
// Cannot use py::gil_scoped_acquire here since that constructor calls get_internals.
413-
struct gil_scoped_acquire_local {
414-
gil_scoped_acquire_local() : state(PyGILState_Ensure()) {}
415-
gil_scoped_acquire_local(const gil_scoped_acquire_local &) = delete;
416-
gil_scoped_acquire_local &operator=(const gil_scoped_acquire_local &) = delete;
417-
~gil_scoped_acquire_local() { PyGILState_Release(state); }
418-
const PyGILState_STATE state;
419-
} gil;
412+
gil_scoped_acquire gil;
420413
error_scope err_scope;
421414

422415
PYBIND11_STR_TYPE id(PYBIND11_INTERNALS_ID);

0 commit comments

Comments
 (0)