Skip to content

Commit f5804e3

Browse files
committed
Move is_finalizing() back to pybind11.h
1 parent 461e81a commit f5804e3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

include/pybind11/detail/common.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -695,19 +695,6 @@ using expand_side_effects = bool[];
695695
#define PYBIND11_EXPAND_SIDE_EFFECTS(PATTERN) (void)pybind11::detail::expand_side_effects{ ((PATTERN), void(), false)..., false }
696696
#endif
697697

698-
// Thread state manipulation C API should not be called while Python runtime is finalizing.
699-
// For more detail see https://docs.python.org/3.7/c-api/init.html#c.PyEval_RestoreThread
700-
// `is_finalizing()` provides a version agnostic way to check if runtime is finalizing.
701-
inline bool is_finalizing() {
702-
#if PY_MAJOR_VERSION < 3
703-
return false;
704-
#elif PY_VERSION_HEX >= 0x03070000
705-
return _Py_IsFinalizing();
706-
#else
707-
return _Py_Finalizing;
708-
#endif
709-
}
710-
711698
PYBIND11_NAMESPACE_END(detail)
712699

713700
/// C++ bindings of builtin Python exceptions

include/pybind11/pybind11.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,19 @@ inline void add_class_method(object& cls, const char *name_, const cpp_function
11681168
}
11691169
}
11701170

1171+
// Thread state manipulation C API should not be called while Python runtime is finalizing.
1172+
// For more detail see https://docs.python.org/3.7/c-api/init.html#c.PyEval_RestoreThread
1173+
// `is_finalizing()` provides a version agnostic way to check if runtime is finalizing.
1174+
inline bool is_finalizing() {
1175+
#if PY_MAJOR_VERSION < 3
1176+
return false;
1177+
#elif PY_VERSION_HEX >= 0x03070000
1178+
return _Py_IsFinalizing();
1179+
#else
1180+
return _Py_Finalizing;
1181+
#endif
1182+
}
1183+
11711184
PYBIND11_NAMESPACE_END(detail)
11721185

11731186
/// Given a pointer to a member function, cast it to its `Derived` version.

0 commit comments

Comments
 (0)