summaryrefslogtreecommitdiffstats
path: root/Programs
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-23 02:12:27 (GMT)
committerGitHub <noreply@github.com>2019-05-23 02:12:27 (GMT)
commit20e1e2582e5e69e43af88ff58699c8883d146acb (patch)
tree2726fa5c02f6b7ddd00eede7ecdaa2f5587e6fd7 /Programs
parentbc2aa816620c5e02ad8e94d8514b7e8f3f551ca1 (diff)
downloadcpython-20e1e2582e5e69e43af88ff58699c8883d146acb.zip
cpython-20e1e2582e5e69e43af88ff58699c8883d146acb.tar.gz
cpython-20e1e2582e5e69e43af88ff58699c8883d146acb.tar.bz2
bpo-36763: Fix _PyPreConfig_InitCompatConfig() utf8_mode (GH-13518)
* _PyPreConfig_InitCompatConfig() sets utf8_mode to 0. * Change Py_UTF8Mode default value to 0. * Fix _PyPreConfig_Copy(): copy also _config_init attrbibute. * _PyPreConfig_AsDict() exports _config_init * Fix _PyPreConfig_GetGlobalConfig(): use Py_UTF8Mode if it's greater than 0, even if utf8_mode >= 0. * Add unit tests on environment variables using Python API.
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_testembed.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 7f8ea07..6bd55de 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -638,7 +638,7 @@ static void set_all_env_vars(void)
}
-static int test_init_env(void)
+static int test_init_compat_env(void)
{
/* Test initialization from environment variables */
Py_IgnoreEnvironmentFlag = 0;
@@ -650,6 +650,29 @@ static int test_init_env(void)
}
+static int test_init_python_env(void)
+{
+ _PyInitError err;
+
+ set_all_env_vars();
+
+ _PyCoreConfig config;
+ err = _PyCoreConfig_InitPythonConfig(&config);
+ if (_PyInitError_Failed(err)) {
+ _Py_ExitInitError(err);
+ }
+ config.program_name = L"./_testembed";
+
+ err = _Py_InitializeFromConfig(&config);
+ if (_PyInitError_Failed(err)) {
+ _Py_ExitInitError(err);
+ }
+ dump_config();
+ Py_Finalize();
+ return 0;
+}
+
+
static void set_all_env_vars_dev_mode(void)
{
putenv("PYTHONMALLOC=");
@@ -1257,7 +1280,8 @@ static struct TestCase TestCases[] = {
{"test_init_from_config", test_init_from_config},
{"test_init_parse_argv", test_init_parse_argv},
{"test_init_dont_parse_argv", test_init_dont_parse_argv},
- {"test_init_env", test_init_env},
+ {"test_init_compat_env", test_init_compat_env},
+ {"test_init_python_env", test_init_python_env},
{"test_init_env_dev_mode", test_init_env_dev_mode},
{"test_init_env_dev_mode_alloc", test_init_env_dev_mode_alloc},
{"test_init_dont_configure_locale", test_init_dont_configure_locale},