Skip to content
3 changes: 2 additions & 1 deletion include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ PYBIND11_WARNING_POP
#endif

// See description of PR #4246:
#if !defined(NDEBUG) && !defined(PY_ASSERT_GIL_HELD_INCREF_DECREF) && !defined(PYPY_VERSION) \
#if !defined(PYBIND11_NO_GIL_CHECKS) && !defined(NDEBUG) \
&& !defined(PY_ASSERT_GIL_HELD_INCREF_DECREF) && !defined(PYPY_VERSION) \
&& !defined(PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF)
# define PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
#endif
Expand Down
4 changes: 3 additions & 1 deletion include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ class handle : public detail::object_api<handle> {
stderr,
"%s is being called while the GIL is either not held or invalid. Please see "
"https://pybind11.readthedocs.io/en/stable/advanced/"
"misc.html#common-sources-of-global-interpreter-lock-errors for debugging advice.\n",
"misc.html#common-sources-of-global-interpreter-lock-errors for debugging advice.\n"
"If you are absolutely sure there is no bug, you can #define PYBIND11_NO_GIL_CHECKS "
"to disable this check.",
function_name.c_str());
fflush(stderr);
if (Py_TYPE(m_ptr)->tp_name != nullptr) {
Expand Down