summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorBrett Simmers <swtaarrs@users.noreply.github.com>2024-05-02 22:25:36 (GMT)
committerGitHub <noreply@github.com>2024-05-02 22:25:36 (GMT)
commitf8290df63f1fd970dfd6bbfdc9a86341a9f97d05 (patch)
tree295dd866e9306b1d8ed7eda44872fd1d151b391d /Python/pystate.c
parent4e2caf2aa046bf80e87e9b858837bb527459a034 (diff)
downloadcpython-f8290df63f1fd970dfd6bbfdc9a86341a9f97d05.zip
cpython-f8290df63f1fd970dfd6bbfdc9a86341a9f97d05.tar.gz
cpython-f8290df63f1fd970dfd6bbfdc9a86341a9f97d05.tar.bz2
gh-116738: Make `_codecs` module thread-safe (#117530)
The module itself is a thin wrapper around calls to functions in `Python/codecs.c`, so that's where the meaningful changes happened: - Move codecs-related state that lives on `PyInterpreterState` to a struct declared in `pycore_codecs.h`. - In free-threaded builds, add a mutex to `codecs_state` to synchronize operations on `search_path`. Because `search_path_mutex` is used as a normal mutex and not a critical section, we must be extremely careful with operations called while holding it. - The codec registry is explicitly initialized as part of `_PyUnicode_InitEncodings` to simplify thread-safety.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 3d6e76e..f442d87 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -843,9 +843,7 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
}
PyConfig_Clear(&interp->config);
- Py_CLEAR(interp->codec_search_path);
- Py_CLEAR(interp->codec_search_cache);
- Py_CLEAR(interp->codec_error_registry);
+ _PyCodec_Fini(interp);
assert(interp->imports.modules == NULL);
assert(interp->imports.modules_by_index == NULL);