File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
25
25
# define PYBIND11_TLS_GET_VALUE (key ) PyThread_tss_get((key))
26
26
# define PYBIND11_TLS_REPLACE_VALUE (key, value ) PyThread_tss_set((key), (value))
27
27
# define PYBIND11_TLS_DELETE_VALUE (key ) PyThread_tss_set((key), nullptr )
28
+ # define PYBIND11_TLS_FREE (key ) PyThread_tss_free(key)
28
29
#else
29
30
// Usually an int but a long on Cygwin64 with Python 3.x
30
31
# define PYBIND11_TLS_KEY_INIT (var ) decltype (PyThread_create_key()) var = 0
@@ -43,6 +44,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
43
44
# define PYBIND11_TLS_REPLACE_VALUE (key, value ) \
44
45
PyThread_set_key_value ((key), (value))
45
46
# endif
47
+ # define PYBIND11_TLS_FREE (key ) (void )key
46
48
#endif
47
49
48
50
// Python loads modules by default with dlopen with the RTLD_LOCAL flag; under libc++ and possibly
Original file line number Diff line number Diff line change @@ -158,6 +158,11 @@ inline void finalize_interpreter() {
158
158
if (builtins.contains (id) && isinstance<capsule>(builtins[id]))
159
159
internals_ptr_ptr = capsule (builtins[id]);
160
160
161
+ #if defined(WITH_THREAD)
162
+ if (internals_ptr_ptr && *internals_ptr_ptr)
163
+ PYBIND11_TLS_FREE ((*internals_ptr_ptr)->tstate );
164
+ #endif
165
+
161
166
Py_Finalize ();
162
167
163
168
if (internals_ptr_ptr) {
You can’t perform that action at this time.
0 commit comments