diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-10-01 08:56:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-01 08:56:37 (GMT) |
commit | 3c30a76f3d3c0dcc1fb4de097fa4a3a4c92c0b0b (patch) | |
tree | bb73b56814d30967e67cc61eb8b66cab83477c3a /Programs | |
parent | 94e165096fd65e8237e60de570fb609604ab94c9 (diff) | |
download | cpython-3c30a76f3d3c0dcc1fb4de097fa4a3a4c92c0b0b.zip cpython-3c30a76f3d3c0dcc1fb4de097fa4a3a4c92c0b0b.tar.gz cpython-3c30a76f3d3c0dcc1fb4de097fa4a3a4c92c0b0b.tar.bz2 |
bpo-38304: Remove PyConfig.struct_size (GH-16500) (GH-16508)
For now, we'll rely on the fact that the config structures aren't covered by the stable ABI.
We may revisit this in the future if we further explore the idea of offering a stable embedding API.
(cherry picked from commit bdace21b769998396d0ccc8da99a8ca9b507bfdf)
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_freeze_importlib.c | 1 | ||||
-rw-r--r-- | Programs/_testembed.c | 109 |
2 files changed, 17 insertions, 93 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c index 7c494c2..74735f2 100644 --- a/Programs/_freeze_importlib.c +++ b/Programs/_freeze_importlib.c @@ -78,7 +78,6 @@ main(int argc, char *argv[]) PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitIsolatedConfig(&config); if (PyStatus_Exception(status)) { diff --git a/Programs/_testembed.c b/Programs/_testembed.c index c8600d5..d2d4c7f 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -385,12 +385,7 @@ static int check_init_compat_config(int preinit) if (preinit) { PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = _PyPreConfig_InitCompatConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + _PyPreConfig_InitCompatConfig(&preconfig); status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { @@ -399,7 +394,6 @@ static int check_init_compat_config(int preinit) } PyConfig config; - config.struct_size = sizeof(PyConfig); status = _PyConfig_InitCompatConfig(&config); if (PyStatus_Exception(status)) { @@ -478,15 +472,8 @@ static int test_init_global_config(void) static int test_init_from_config(void) { - PyStatus status; - PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = _PyPreConfig_InitCompatConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + _PyPreConfig_InitCompatConfig(&preconfig); putenv("PYTHONMALLOC=malloc_debug"); preconfig.allocator = PYMEM_ALLOCATOR_MALLOC; @@ -495,13 +482,12 @@ static int test_init_from_config(void) Py_UTF8Mode = 0; preconfig.utf8_mode = 1; - status = Py_PreInitialize(&preconfig); + PyStatus status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } PyConfig config; - config.struct_size = sizeof(PyConfig); status = _PyConfig_InitCompatConfig(&config); if (PyStatus_Exception(status)) { @@ -638,7 +624,6 @@ static int check_init_parse_argv(int parse_argv) PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -725,7 +710,6 @@ static int test_init_python_env(void) set_all_env_vars(); PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -780,7 +764,6 @@ static int test_init_isolated_flag(void) /* Test PyConfig.isolated=1 */ PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -803,25 +786,17 @@ static int test_init_isolated_flag(void) /* PyPreConfig.isolated=1, PyConfig.isolated=0 */ static int test_preinit_isolated1(void) { - PyStatus status; - PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = _PyPreConfig_InitCompatConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + _PyPreConfig_InitCompatConfig(&preconfig); preconfig.isolated = 1; - status = Py_PreInitialize(&preconfig); + PyStatus status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } PyConfig config; - config.struct_size = sizeof(PyConfig); status = _PyConfig_InitCompatConfig(&config); if (PyStatus_Exception(status)) { @@ -840,26 +815,19 @@ static int test_preinit_isolated1(void) /* PyPreConfig.isolated=0, PyConfig.isolated=1 */ static int test_preinit_isolated2(void) { - PyStatus status; - PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = _PyPreConfig_InitCompatConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + _PyPreConfig_InitCompatConfig(&preconfig); preconfig.isolated = 0; - status = Py_PreInitialize(&preconfig); + PyStatus status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } /* Test PyConfig.isolated=1 */ PyConfig config; - config.struct_size = sizeof(PyConfig); + status = _PyConfig_InitCompatConfig(&config); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); @@ -880,15 +848,8 @@ static int test_preinit_isolated2(void) static int test_preinit_dont_parse_argv(void) { - PyStatus status; - PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = PyPreConfig_InitIsolatedConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + PyPreConfig_InitIsolatedConfig(&preconfig); preconfig.isolated = 0; @@ -899,13 +860,13 @@ static int test_preinit_dont_parse_argv(void) L"-X", L"dev", L"-X", L"utf8", L"script.py"}; - status = Py_PreInitializeFromArgs(&preconfig, Py_ARRAY_LENGTH(argv), argv); + PyStatus status = Py_PreInitializeFromArgs(&preconfig, + Py_ARRAY_LENGTH(argv), argv); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitIsolatedConfig(&config); if (PyStatus_Exception(status)) { @@ -931,7 +892,6 @@ static int test_preinit_parse_argv(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -989,12 +949,7 @@ static int check_preinit_isolated_config(int preinit) if (preinit) { PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = PyPreConfig_InitIsolatedConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + PyPreConfig_InitIsolatedConfig(&preconfig); status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { @@ -1007,7 +962,6 @@ static int check_preinit_isolated_config(int preinit) } PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitIsolatedConfig(&config); if (PyStatus_Exception(status)) { @@ -1058,12 +1012,7 @@ static int check_init_python_config(int preinit) if (preinit) { PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = PyPreConfig_InitPythonConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + PyPreConfig_InitPythonConfig(&preconfig); status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { @@ -1072,7 +1021,6 @@ static int check_init_python_config(int preinit) } PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1101,27 +1049,19 @@ static int test_init_python_config(void) static int test_init_dont_configure_locale(void) { - PyStatus status; - PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = PyPreConfig_InitPythonConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + PyPreConfig_InitPythonConfig(&preconfig); preconfig.configure_locale = 0; preconfig.coerce_c_locale = 1; preconfig.coerce_c_locale_warn = 1; - status = Py_PreInitialize(&preconfig); + PyStatus status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1140,7 +1080,6 @@ static int test_init_dev_mode(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1365,7 +1304,6 @@ static int run_audit_run_test(int argc, wchar_t **argv, void *test) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1415,7 +1353,6 @@ static int test_init_read_set(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1465,7 +1402,6 @@ static int test_init_sys_add(void) PySys_AddWarnOption(L"ignore:::sysadd_warnoption"); PyConfig config; - config.struct_size = sizeof(PyConfig); PyStatus status; status = PyConfig_InitPythonConfig(&config); @@ -1533,18 +1469,12 @@ static int test_init_setpath(void) static int test_init_setpath_config(void) { - PyStatus status; PyPreConfig preconfig; - preconfig.struct_size = sizeof(PyPreConfig); - - status = PyPreConfig_InitPythonConfig(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } + PyPreConfig_InitPythonConfig(&preconfig); /* Explicitly preinitializes with Python preconfiguration to avoid Py_SetPath() implicit preinitialization with compat preconfiguration. */ - status = Py_PreInitialize(&preconfig); + PyStatus status = Py_PreInitialize(&preconfig); if (PyStatus_Exception(status)) { Py_ExitStatusException(status); } @@ -1564,7 +1494,6 @@ static int test_init_setpath_config(void) putenv("TESTPATH="); PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1612,7 +1541,6 @@ static int test_init_warnoptions(void) PySys_AddWarnOption(L"ignore:::PySys_AddWarnOption2"); PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1680,7 +1608,6 @@ static int test_init_run_main(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1697,7 +1624,6 @@ static int test_init_main(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { @@ -1729,7 +1655,6 @@ static int test_run_main(void) { PyStatus status; PyConfig config; - config.struct_size = sizeof(PyConfig); status = PyConfig_InitPythonConfig(&config); if (PyStatus_Exception(status)) { |