diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 80a3a1f2..1cf0cd9b 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -128,10 +128,6 @@ } \ PyObject *pybind11_init() -extern "C" { - extern PyThreadState *_PyThreadState_Current; -}; - NAMESPACE_BEGIN(pybind11) typedef Py_ssize_t ssize_t; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index ae044c3b..d4148b07 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1070,7 +1070,7 @@ public: tstate->gilstate_counter = 0; PyThread_set_key_value(internals.tstate, tstate); } else { - release = _PyThreadState_Current != tstate; + release = PyThreadState_GET() != tstate; } if (release) { @@ -1091,7 +1091,7 @@ public: void dec_ref() { --tstate->gilstate_counter; #if !defined(NDEBUG) - if (_PyThreadState_Current != tstate) + if (PyThreadState_GET() != tstate) pybind11_fail("scoped_acquire::dec_ref(): thread state must be current!"); if (tstate->gilstate_counter < 0) pybind11_fail("scoped_acquire::dec_ref(): reference count underflow!");