diff options
| author | Victor Stinner <vstinner@redhat.com> | 2019-08-23 19:16:51 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-23 19:16:51 (GMT) |
| commit | af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6 (patch) | |
| tree | b9f0a48a09eb7783ee3b35e9f2381ea2f791b9d9 /Programs | |
| parent | 3921d12174c1998d9df7a08d036a7fef2d587a64 (diff) | |
| download | cpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.zip cpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.tar.gz cpython-af84a88ef8b3288da528d2f52b7d3fbafb8dc8a6.tar.bz2 | |
bpo-36763: PyConfig_Read() handles PySys_AddXOption() (GH-15431) (GH-15435)
PyConfig_Read() is now responsible to handle early calls to
PySys_AddXOption() and PySys_AddWarnOption().
Options added by PySys_AddXOption() are now handled the same way than
PyConfig.xoptions and command line -X options.
For example, PySys_AddXOption(L"faulthandler") enables faulthandler
as expected.
(cherry picked from commit 120b707a6d43452e067daa55a8fdca69f9424abc)
Diffstat (limited to 'Programs')
| -rw-r--r-- | Programs/_testembed.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 3873009..c3ccc0e 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -1375,6 +1375,54 @@ fail: } +static int test_init_sys_add(void) +{ + PySys_AddXOption(L"sysadd_xoption"); + PySys_AddXOption(L"faulthandler"); + PySys_AddWarnOption(L"ignore:::sysadd_warnoption"); + + PyConfig config; + PyStatus status; + status = PyConfig_InitPythonConfig(&config); + if (PyStatus_Exception(status)) { + goto fail; + } + + wchar_t* argv[] = { + L"python3", + L"-W", + L"ignore:::cmdline_warnoption", + L"-X", + L"cmdline_xoption", + }; + config_set_argv(&config, Py_ARRAY_LENGTH(argv), argv); + config.parse_argv = 1; + + status = PyWideStringList_Append(&config.xoptions, + L"config_xoption"); + if (PyStatus_Exception(status)) { + goto fail; + } + + status = PyWideStringList_Append(&config.warnoptions, + L"ignore:::config_warnoption"); + if (PyStatus_Exception(status)) { + goto fail; + } + + config_set_program_name(&config); + init_from_config_clear(&config); + + dump_config(); + Py_Finalize(); + return 0; + +fail: + PyConfig_Clear(&config); + Py_ExitStatusException(status); +} + + static void configure_init_main(PyConfig *config) { wchar_t* argv[] = { @@ -1510,6 +1558,7 @@ static struct TestCase TestCases[] = { {"test_init_read_set", test_init_read_set}, {"test_init_run_main", test_init_run_main}, {"test_init_main", test_init_main}, + {"test_init_sys_add", test_init_sys_add}, {"test_run_main", test_run_main}, {"test_open_code_hook", test_open_code_hook}, {"test_audit", test_audit}, |
