From 3d16fc90ce36acaa846ee88bdd124f84d49395b3 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 20 Sep 2021 01:47:58 -0700 Subject: bpo-40413: test_embed tests calling Py_RunMain() multiple times (GH-28466) Calling Py_InitializeFromConfig()+Py_RunMain() multiple times must not crash. Cleanup also test_get_argc_argv(). (cherry picked from commit 5e2c32e08ed77081cabd9d51f0589f81c1572732) Co-authored-by: Victor Stinner --- Lib/test/test_embed.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Lib/test') diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 479d712da6..0a66e7f6b9 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -311,6 +311,14 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase): self.assertEqual(out.rstrip(), "Py_RunMain(): sys.argv=['-c', 'arg2']") self.assertEqual(err, '') + def test_run_main_loop(self): + # bpo-40413: Calling Py_InitializeFromConfig()+Py_RunMain() multiple + # times must not crash. + nloop = 5 + out, err = self.run_embedded_interpreter("test_run_main_loop") + self.assertEqual(out, "Py_RunMain(): sys.argv=['-c', 'arg2']\n" * nloop) + self.assertEqual(err, '') + class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): maxDiff = 4096 -- cgit v1.2.1