summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
Diffstat (limited to 'Include')
-rw-r--r--Include/internal/pycore_import.h20
-rw-r--r--Include/internal/pycore_pystate.h5
-rw-r--r--Include/internal/pycore_runtime_init.h5
3 files changed, 23 insertions, 7 deletions
diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h
index 69ed627..7a78a91 100644
--- a/Include/internal/pycore_import.h
+++ b/Include/internal/pycore_import.h
@@ -14,13 +14,19 @@ struct _import_runtime_state {
which is just about every time an extension module is imported.
See PyInterpreterState.modules_by_index for more info. */
Py_ssize_t last_module_index;
- /* A dict mapping (filename, name) to PyModuleDef for modules.
- Only legacy (single-phase init) extension modules are added
- and only if they support multiple initialization (m_size >- 0)
- or are imported in the main interpreter.
- This is initialized lazily in _PyImport_FixupExtensionObject().
- Modules are added there and looked up in _imp.find_extension(). */
- PyObject *extensions;
+ struct {
+ /* A thread state tied to the main interpreter,
+ used exclusively for when the extensions dict is access/modified
+ from an arbitrary thread. */
+ PyThreadState main_tstate;
+ /* A dict mapping (filename, name) to PyModuleDef for modules.
+ Only legacy (single-phase init) extension modules are added
+ and only if they support multiple initialization (m_size >- 0)
+ or are imported in the main interpreter.
+ This is initialized lazily in _PyImport_FixupExtensionObject().
+ Modules are added there and looked up in _imp.find_extension(). */
+ PyObject *dict;
+ } extensions;
/* Package context -- the full module name for package imports */
const char * pkgcontext;
};
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 7046ec8..b540862 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -127,6 +127,11 @@ PyAPI_FUNC(void) _PyThreadState_Init(
PyThreadState *tstate);
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
+extern void _PyThreadState_InitDetached(PyThreadState *, PyInterpreterState *);
+extern void _PyThreadState_ClearDetached(PyThreadState *);
+extern void _PyThreadState_BindDetached(PyThreadState *);
+extern void _PyThreadState_UnbindDetached(PyThreadState *);
+
static inline void
_PyThreadState_UpdateTracingState(PyThreadState *tstate)
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
index 7cfa7c0..5b09a45 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -41,6 +41,11 @@ extern PyTypeObject _PyExc_MemoryError;
in accordance with the specification. */ \
.autoTSSkey = Py_tss_NEEDS_INIT, \
.parser = _parser_runtime_state_INIT, \
+ .imports = { \
+ .extensions = { \
+ .main_tstate = _PyThreadState_INIT, \
+ }, \
+ }, \
.ceval = { \
.perf = _PyEval_RUNTIME_PERF_INIT, \
}, \