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 /Modules/main.c | |
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 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/Modules/main.c b/Modules/main.c index 7665769..42d2c3c 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -567,20 +567,22 @@ exit_sigint(void) } -static int -pymain_main(_PyArgv *args) +static void _Py_NO_RETURN +pymain_exit_error(_PyInitError err) { - _PyInitError err; + pymain_free(); + _Py_ExitInitError(err); +} - err = pymain_init(args); - if (_Py_INIT_FAILED(err)) { - goto exit_init_error; - } +int +_Py_RunMain(void) +{ int exitcode = 0; - err = pymain_run_python(&exitcode); + + _PyInitError err = pymain_run_python(&exitcode); if (_Py_INIT_FAILED(err)) { - goto exit_init_error; + pymain_exit_error(err); } if (Py_FinalizeEx() < 0) { @@ -596,10 +598,18 @@ pymain_main(_PyArgv *args) } return exitcode; +} -exit_init_error: - pymain_free(); - _Py_ExitInitError(err); + +static int +pymain_main(_PyArgv *args) +{ + _PyInitError err = pymain_init(args); + if (_Py_INIT_FAILED(err)) { + pymain_exit_error(err); + } + + return _Py_RunMain(); } |