summaryrefslogtreecommitdiffstats
path: root/Python/preconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-05 14:41:11 (GMT)
committerGitHub <noreply@github.com>2020-05-05 14:41:11 (GMT)
commitc5fa364f4ea836f25dd07cfb328152d40a568371 (patch)
tree34e2aa87ac5abc14ac1d79eb0f862fb526fda481 /Python/preconfig.c
parent0b1e3307e24b0af45787ab6456535b8346e0239a (diff)
downloadcpython-c5fa364f4ea836f25dd07cfb328152d40a568371.zip
cpython-c5fa364f4ea836f25dd07cfb328152d40a568371.tar.gz
cpython-c5fa364f4ea836f25dd07cfb328152d40a568371.tar.bz2
bpo-40514: Add --with-experimental-isolated-subinterpreters (GH-19926)
Add --with-experimental-isolated-subinterpreters build option to configure: better isolate subinterpreters, experimental build mode. When used, force the usage of the libc malloc() memory allocator, since pymalloc relies on the unique global interpreter lock (GIL).
Diffstat (limited to 'Python/preconfig.c')
-rw-r--r--Python/preconfig.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Python/preconfig.c b/Python/preconfig.c
index 262738f..fd94d7d 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -291,7 +291,17 @@ _PyPreConfig_InitCompatConfig(PyPreConfig *config)
config->coerce_c_locale_warn = 0;
config->dev_mode = -1;
+#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
+ /* bpo-40512: pymalloc is not compatible with subinterpreters,
+ force usage of libc malloc() which is thread-safe. */
+#ifdef Py_DEBUG
+ config->allocator = PYMEM_ALLOCATOR_MALLOC_DEBUG;
+#else
+ config->allocator = PYMEM_ALLOCATOR_MALLOC;
+#endif
+#else
config->allocator = PYMEM_ALLOCATOR_NOT_SET;
+#endif
#ifdef MS_WINDOWS
config->legacy_windows_fs_encoding = -1;
#endif