mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-36763: Add _PyCoreConfig.parse_argv (GH-13361)
* _PyCoreConfig_Read() doesn't parse nor update argv if parse_argv is 0. * Move path configuration fields in _PyCoreConfig. * Add an unit test for parse_argv=0. * Remove unused "done": label in _Py_RunMain().
This commit is contained in:
parent
68b34a7204
commit
ae239f6b06
5 changed files with 109 additions and 36 deletions
|
@ -511,6 +511,37 @@ static int test_init_from_config(void)
|
|||
}
|
||||
|
||||
|
||||
static int test_init_dont_parse_argv(void)
|
||||
{
|
||||
_PyInitError err;
|
||||
|
||||
_PyCoreConfig config = _PyCoreConfig_INIT;
|
||||
|
||||
static wchar_t* argv[] = {
|
||||
L"-v",
|
||||
L"-c",
|
||||
L"arg1",
|
||||
L"-W",
|
||||
L"arg2",
|
||||
};
|
||||
|
||||
config.program = L"program";
|
||||
config.program_name = L"./_testembed";
|
||||
|
||||
config.argv.length = Py_ARRAY_LENGTH(argv);
|
||||
config.argv.items = argv;
|
||||
config.parse_argv = 0;
|
||||
|
||||
err = _Py_InitializeFromConfig(&config);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
_Py_ExitInitError(err);
|
||||
}
|
||||
dump_config();
|
||||
Py_Finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void test_init_env_putenvs(void)
|
||||
{
|
||||
putenv("PYTHONHASHSEED=42");
|
||||
|
@ -797,6 +828,7 @@ static struct TestCase TestCases[] = {
|
|||
{ "init_default_config", test_init_default_config },
|
||||
{ "init_global_config", test_init_global_config },
|
||||
{ "init_from_config", test_init_from_config },
|
||||
{ "init_dont_parse_argv", test_init_dont_parse_argv },
|
||||
{ "init_env", test_init_env },
|
||||
{ "init_env_dev_mode", test_init_env_dev_mode },
|
||||
{ "init_env_dev_mode_alloc", test_init_env_dev_mode_alloc },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue