Skip to content

Provide PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF as an option #4753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 17, 2023
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