| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -311,6 +311,14 @@ def test_run_main(self): | |||
| 311 | 311 | self.assertEqual(out.rstrip(), "Py_RunMain(): sys.argv=['-c', 'arg2']") | |
| 312 | 312 | self.assertEqual(err, '') | |
| 313 | 313 | ||
| 314 | + def test_run_main_loop(self): | ||
| 315 | + # bpo-40413: Calling Py_InitializeFromConfig()+Py_RunMain() multiple | ||
| 316 | + # times must not crash. | ||
| 317 | + nloop = 5 | ||
| 318 | + out, err = self.run_embedded_interpreter("test_run_main_loop") | ||
| 319 | + self.assertEqual(out, "Py_RunMain(): sys.argv=['-c', 'arg2']\n" * nloop) | ||
| 320 | + self.assertEqual(err, '') | ||
| 321 | + | ||
| 314 | 322 | ||
| 315 | 323 | class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): | |
| 316 | 324 | maxDiff = 4096 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1662,15 +1662,26 @@ static int test_run_main(void) | |||
| 1662 | 1662 | } | |
| 1663 | 1663 | ||
| 1664 | 1664 | ||
| 1665 | + static int test_run_main_loop(void) | ||
| 1666 | + { | ||
| 1667 | + // bpo-40413: Calling Py_InitializeFromConfig()+Py_RunMain() multiple | ||
| 1668 | + // times must not crash. | ||
| 1669 | + for (int i=0; i<5; i++) { | ||
| 1670 | + int exitcode = test_run_main(); | ||
| 1671 | + if (exitcode != 0) { | ||
| 1672 | + return exitcode; | ||
| 1673 | + } | ||
| 1674 | + } | ||
| 1675 | + return 0; | ||
| 1676 | + } | ||
| 1677 | + | ||
| 1678 | + | ||
| 1665 | 1679 | static int test_get_argc_argv(void) | |
| 1666 | 1680 | { | |
| 1667 | 1681 | PyConfig config; | |
| 1668 | 1682 | PyConfig_InitPythonConfig(&config); | |
| 1669 | 1683 | ||
| 1670 | - wchar_t *argv[] = {L"python3", L"-c", | ||
| 1671 | - (L"import sys; " | ||
| 1672 | - L"print(f'Py_RunMain(): sys.argv={sys.argv}')"), | ||
| 1673 | - L"arg2"}; | ||
| 1684 | + wchar_t *argv[] = {L"python3", L"-c", L"pass", L"arg2"}; | ||
| 1674 | 1685 | config_set_argv(&config, Py_ARRAY_LENGTH(argv), argv); | |
| 1675 | 1686 | config_set_string(&config, &config.program_name, L"./python3"); | |
| 1676 | 1687 | ||
@@ -1844,6 +1855,7 @@ static struct TestCase TestCases[] = { | |||
| 1844 | 1855 | {"test_init_warnoptions", test_init_warnoptions}, | |
| 1845 | 1856 | {"test_init_set_config", test_init_set_config}, | |
| 1846 | 1857 | {"test_run_main", test_run_main}, | |
| 1858 | + {"test_run_main_loop", test_run_main_loop}, | ||
| 1847 | 1859 | {"test_get_argc_argv", test_get_argc_argv}, | |
| 1848 | 1860 | ||
| 1849 | 1861 | // Audit | |
| Back | FazBrowse Home | New Git URL |
0 commit comments