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 5e2c32e08e)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2021-09-20 01:47:58 -07:00 committed by GitHub
parent 697b6650ed
commit 3d16fc90ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View file

@ -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