summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 5c1636a..d31c1f1 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -400,6 +400,11 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
return status;
}
+ if (PyThread_tss_create(&runtime->trashTSSkey) != 0) {
+ _PyRuntimeState_Fini(runtime);
+ return _PyStatus_NO_MEMORY();
+ }
+
init_runtime(runtime, open_code_hook, open_code_userdata, audit_hook_head,
unicode_next_index, lock1, lock2, lock3, lock4);
@@ -413,6 +418,10 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
current_tss_fini(runtime);
}
+ if (PyThread_tss_is_created(&runtime->trashTSSkey)) {
+ PyThread_tss_delete(&runtime->trashTSSkey);
+ }
+
/* Force the allocator used by _PyRuntimeState_Init(). */
PyMemAllocatorEx old_alloc;
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
@@ -471,6 +480,13 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
return status;
}
+ if (PyThread_tss_is_created(&runtime->trashTSSkey)) {
+ PyThread_tss_delete(&runtime->trashTSSkey);
+ }
+ if (PyThread_tss_create(&runtime->trashTSSkey) != 0) {
+ return _PyStatus_NO_MEMORY();
+ }
+
return _PyStatus_OK();
}
#endif