Skip to content

Commit

Permalink
@jbms wrote: We can leave internals.tstate present (depending on ABI …
Browse files Browse the repository at this point in the history
…version), to avoid breaking ABI compatibility. (pybind#4216 (comment))
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Oct 6, 2022
1 parent ad126f5 commit be83638
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ struct internals {
PyTypeObject *default_metaclass;
PyObject *instance_base;
#if defined(WITH_THREAD)
# if PYBIND11_INTERNALS_VERSION > 5
PYBIND11_TLS_KEY_INIT(tstate)
# endif // PYBIND11_INTERNALS_VERSION > 5
# if PYBIND11_INTERNALS_VERSION > 4
PYBIND11_TLS_KEY_INIT(loader_life_support_tls_key)
# endif // PYBIND11_INTERNALS_VERSION > 4
Expand All @@ -180,6 +182,7 @@ struct internals {
PYBIND11_TLS_FREE(loader_life_support_tls_key);
# endif // PYBIND11_INTERNALS_VERSION > 4

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

0 comments on commit be83638

Please sign in to comment.