diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 782fb20d4..a0e32281b 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1625,7 +1625,7 @@ unpacking_collector collect_arguments(Args &&...args) { template template object object_api::operator()(Args &&...args) const { -#if defined(PYBIND11_DETAILED_ERROR_MESSAGES) +#ifndef NDEBUG if (!PyGILState_Check()) { pybind11_fail("pybind11::object_api<>::operator() PyGILState_Check() failure."); }