diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-03-29 14:13:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-29 14:13:46 (GMT) |
commit | 2f54908afc5665937d763510b4430f10cf764641 (patch) | |
tree | 8ceaf77d86f93ec2908129e03a4ad872d6e20c22 /Programs | |
parent | 5f45979b63300338b68709bfe817ddae563b93fd (diff) | |
download | cpython-2f54908afc5665937d763510b4430f10cf764641.zip cpython-2f54908afc5665937d763510b4430f10cf764641.tar.gz cpython-2f54908afc5665937d763510b4430f10cf764641.tar.bz2 |
bpo-36471: Add _Py_RunMain() (GH-12618)
* Add config_read_cmdline() subfunction. Remove _PyCmdline structure.
* _PyCoreConfig_Read() now also parses config->argv command line
arguments
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_testembed.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index d8e12cf..7d71a96 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -447,9 +447,11 @@ static int test_init_from_config(void) Py_SetProgramName(L"./globalvar"); config.program_name = L"./conf_program_name"; - static wchar_t* argv[2] = { + static wchar_t* argv[] = { + L"python3", L"-c", L"pass", + L"arg2", }; config.argv.length = Py_ARRAY_LENGTH(argv); config.argv.items = argv; @@ -528,7 +530,6 @@ static int test_init_from_config(void) config._frozen = 1; err = _Py_InitializeFromConfig(&config); - /* Don't call _PyCoreConfig_Clear() since all strings are static */ if (_Py_INIT_FAILED(err)) { _Py_ExitInitError(err); } @@ -712,6 +713,27 @@ static int test_init_dev_mode(void) } +static int test_run_main(void) +{ + _PyCoreConfig config = _PyCoreConfig_INIT; + + wchar_t *argv[] = {L"python3", L"-c", + (L"import sys; " + L"print(f'_Py_RunMain(): sys.argv={sys.argv}')"), + L"arg2"}; + config.argv.length = Py_ARRAY_LENGTH(argv); + config.argv.items = argv; + config.program_name = L"./python3"; + + _PyInitError err = _Py_InitializeFromConfig(&config); + if (_Py_INIT_FAILED(err)) { + _Py_ExitInitError(err); + } + + return _Py_RunMain(); +} + + /* ********************************************************* * List of test cases and the function that implements it. * @@ -748,6 +770,7 @@ static struct TestCase TestCases[] = { { "init_isolated", test_init_isolated }, { "preinit_isolated1", test_preinit_isolated1 }, { "preinit_isolated2", test_preinit_isolated2 }, + { "run_main", test_run_main }, { NULL, NULL } }; |