bpo-36142: Add _PyPreConfig.allocator (GH-12181)
* Move 'allocator' and 'dev_mode' fields from _PyCoreConfig
to _PyPreConfig.
* Fix InitConfigTests of test_embed: dev_mode sets allocator to
"debug", add a new tests for env vars with dev mode enabled.
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index dec8904..c955a1d 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -482,9 +482,9 @@
/* bpo-34008: For backward compatibility reasons, calling Py_Main() after
Py_Initialize() ignores the new configuration. */
- if (core_config->allocator != NULL) {
+ if (core_config->preconfig.allocator != NULL) {
const char *allocator = _PyMem_GetAllocatorsName();
- if (allocator == NULL || strcmp(core_config->allocator, allocator) != 0) {
+ if (allocator == NULL || strcmp(core_config->preconfig.allocator, allocator) != 0) {
return _Py_INIT_USER_ERR("cannot modify memory allocator "
"after first Py_Initialize()");
}
@@ -521,8 +521,8 @@
return err;
}
- if (core_config->allocator != NULL) {
- if (_PyMem_SetupAllocators(core_config->allocator) < 0) {
+ if (core_config->preconfig.allocator != NULL) {
+ if (_PyMem_SetupAllocators(core_config->preconfig.allocator) < 0) {
return _Py_INIT_USER_ERR("Unknown PYTHONMALLOC allocator");
}
}