mirror of
https://github.com/python/cpython.git
synced 2025-09-03 23:41:18 +00:00
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.
This commit is contained in:
parent
359a2f3dab
commit
b35be4b333
7 changed files with 129 additions and 53 deletions
|
@ -482,9 +482,9 @@ _Py_Initialize_ReconfigureCore(PyInterpreterState **interp_p,
|
|||
|
||||
/* 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 @@ pycore_init_runtime(const _PyCoreConfig *core_config)
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue