Skip to content

Commit e5fe8d3

Browse files
committed
Simplify is_finalizing() check
One should follow documentation rather than make any assumptions
1 parent f5804e3 commit e5fe8d3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/pybind11/pybind11.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,12 +1172,10 @@ inline void add_class_method(object& cls, const char *name_, const cpp_function
11721172
// For more detail see https://docs.python.org/3.7/c-api/init.html#c.PyEval_RestoreThread
11731173
// `is_finalizing()` provides a version agnostic way to check if runtime is finalizing.
11741174
inline bool is_finalizing() {
1175-
#if PY_MAJOR_VERSION < 3
1176-
return false;
1177-
#elif PY_VERSION_HEX >= 0x03070000
1175+
#if PY_VERSION_HEX >= 0x03070000
11781176
return _Py_IsFinalizing();
11791177
#else
1180-
return _Py_Finalizing;
1178+
return false;
11811179
#endif
11821180
}
11831181

0 commit comments

Comments
 (0)