@@ -447,9 +447,11 @@ static int test_init_from_config(void)
447447 Py_SetProgramName (L"./globalvar" );
448448 config .program_name = L"./conf_program_name" ;
449449
450- static wchar_t * argv [2 ] = {
450+ static wchar_t * argv [] = {
451+ L"python3" ,
451452 L"-c" ,
452453 L"pass" ,
454+ L"arg2" ,
453455 };
454456 config .argv .length = Py_ARRAY_LENGTH (argv );
455457 config .argv .items = argv ;
@@ -528,7 +530,6 @@ static int test_init_from_config(void)
528530 config ._frozen = 1 ;
529531
530532 err = _Py_InitializeFromConfig (& config );
531- /* Don't call _PyCoreConfig_Clear() since all strings are static */
532533 if (_Py_INIT_FAILED (err )) {
533534 _Py_ExitInitError (err );
534535 }
@@ -712,6 +713,27 @@ static int test_init_dev_mode(void)
712713}
713714
714715
716+ static int test_run_main (void )
717+ {
718+ _PyCoreConfig config = _PyCoreConfig_INIT ;
719+
720+ wchar_t * argv [] = {L"python3" , L"-c" ,
721+ (L"import sys; "
722+ L"print(f'_Py_RunMain(): sys.argv={sys.argv}')" ),
723+ L"arg2" };
724+ config .argv .length = Py_ARRAY_LENGTH (argv );
725+ config .argv .items = argv ;
726+ config .program_name = L"./python3" ;
727+
728+ _PyInitError err = _Py_InitializeFromConfig (& config );
729+ if (_Py_INIT_FAILED (err )) {
730+ _Py_ExitInitError (err );
731+ }
732+
733+ return _Py_RunMain ();
734+ }
735+
736+
715737/* *********************************************************
716738 * List of test cases and the function that implements it.
717739 *
@@ -748,6 +770,7 @@ static struct TestCase TestCases[] = {
748770 { "init_isolated" , test_init_isolated },
749771 { "preinit_isolated1" , test_preinit_isolated1 },
750772 { "preinit_isolated2" , test_preinit_isolated2 },
773+ { "run_main" , test_run_main },
751774 { NULL , NULL }
752775};
753776
0 commit comments