summaryrefslogtreecommitdiff
path: root/Programs
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-05 17:37:44 +0100
committerGitHub <noreply@github.com>2019-03-05 17:37:44 +0100
commitb35be4b3334fbc471a39abbeb68110867b72e3e5 (patch)
tree4c311249db97ae7ebc5d2cb9ed48791549512afe /Programs
parent359a2f3daba49fde0d3a07fb3c7a8b051c450d08 (diff)
downloadcpython-git-b35be4b3334fbc471a39abbeb68110867b72e3e5.tar.gz
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.
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_testembed.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 9923f8df20..70bf96036a 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -437,7 +437,7 @@ static int test_init_from_config(void)
config.hash_seed = 123;
putenv("PYTHONMALLOC=malloc");
- config.allocator = "malloc_debug";
+ config.preconfig.allocator = "malloc_debug";
/* dev_mode=1 is tested in test_init_dev_mode() */
@@ -577,7 +577,6 @@ static void test_init_env_putenvs(void)
putenv("PYTHONPYCACHEPREFIX=env_pycache_prefix");
putenv("PYTHONNOUSERSITE=1");
putenv("PYTHONFAULTHANDLER=1");
- putenv("PYTHONDEVMODE=1");
putenv("PYTHONIOENCODING=iso8859-1:replace");
/* FIXME: test PYTHONWARNINGS */
/* FIXME: test PYTHONEXECUTABLE */
@@ -589,6 +588,15 @@ static void test_init_env_putenvs(void)
}
+static void test_init_env_dev_mode_putenvs(void)
+{
+ test_init_env_putenvs();
+ putenv("PYTHONMALLOC=malloc");
+ putenv("PYTHONFAULTHANDLER=");
+ putenv("PYTHONDEVMODE=1");
+}
+
+
static int test_init_env(void)
{
/* Test initialization from environment variables */
@@ -601,6 +609,18 @@ static int test_init_env(void)
}
+static int test_init_env_dev_mode(void)
+{
+ /* Test initialization from environment variables */
+ Py_IgnoreEnvironmentFlag = 0;
+ test_init_env_dev_mode_putenvs();
+ _testembed_Py_Initialize();
+ dump_config();
+ Py_Finalize();
+ return 0;
+}
+
+
static int test_init_isolated(void)
{
/* Test _PyCoreConfig.isolated=1 */
@@ -615,7 +635,7 @@ static int test_init_isolated(void)
/* Use path starting with "./" avoids a search along the PATH */
config.program_name = L"./_testembed";
- test_init_env_putenvs();
+ test_init_env_dev_mode_putenvs();
_PyInitError err = _Py_InitializeFromConfig(&config);
if (_Py_INIT_FAILED(err)) {
_Py_ExitInitError(err);
@@ -631,7 +651,7 @@ static int test_init_dev_mode(void)
_PyCoreConfig config = _PyCoreConfig_INIT;
putenv("PYTHONFAULTHANDLER=");
putenv("PYTHONMALLOC=");
- config.dev_mode = 1;
+ config.preconfig.dev_mode = 1;
config.program_name = L"./_testembed";
_PyInitError err = _Py_InitializeFromConfig(&config);
if (_Py_INIT_FAILED(err)) {
@@ -673,6 +693,7 @@ static struct TestCase TestCases[] = {
{ "init_global_config", test_init_global_config },
{ "init_from_config", test_init_from_config },
{ "init_env", test_init_env },
+ { "init_env_dev_mode", test_init_env_dev_mode },
{ "init_dev_mode", test_init_dev_mode },
{ "init_isolated", test_init_isolated },
{ NULL, NULL }