Skip to content

Commit be83638

Browse files
committed
@jbms wrote: We can leave internals.tstate present (depending on ABI version), to avoid breaking ABI compatibility. (#4216 (comment))
1 parent ad126f5 commit be83638

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/pybind11/detail/internals.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ struct internals {
170170
PyTypeObject *default_metaclass;
171171
PyObject *instance_base;
172172
#if defined(WITH_THREAD)
173+
# if PYBIND11_INTERNALS_VERSION > 5
173174
PYBIND11_TLS_KEY_INIT(tstate)
175+
# endif // PYBIND11_INTERNALS_VERSION > 5
174176
# if PYBIND11_INTERNALS_VERSION > 4
175177
PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
176178
# endif // PYBIND11_INTERNALS_VERSION > 4
@@ -180,6 +182,7 @@ struct internals {
180182
PYBIND11_TLS_FREE(loader_life_support_tls_key);
181183
# endif // PYBIND11_INTERNALS_VERSION > 4
182184

185+
# if PYBIND11_INTERNALS_VERSION > 5
183186
// This destructor is called *after* Py_Finalize() in finalize_interpreter().
184187
// That *SHOULD BE* fine. The following details what happens when PyThread_tss_free is
185188
// called. PYBIND11_TLS_FREE is PyThread_tss_free on python 3.7+. On older python, it does
@@ -188,6 +191,7 @@ struct internals {
188191
// Neither of those have anything to do with CPython internals. PyMem_RawFree *requires*
189192
// that the `tstate` be allocated with the CPython allocator.
190193
PYBIND11_TLS_FREE(tstate);
194+
# endif // PYBIND11_INTERNALS_VERSION > 5
191195
}
192196
#endif
193197
};

0 commit comments

Comments
 (0)