From 7aa250585fde3611b745e7e5ec1d290884f1146a Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Tue, 5 Apr 2022 04:00:24 +0900 Subject: [PATCH 1/2] Remove PYTHONHOME from envvars --- Lib/test/test_embed.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 7e5e4c144851ee..bf49244ca37d8e 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -346,7 +346,8 @@ def test_finalize_structseq(self): def test_ucnhash_capi_reset(self): # bpo-47182: unicodeobject.c:ucnhash_capi was not reset on shutdown. code = "print('\\N{digit nine}')" - out, err = self.run_embedded_interpreter("test_repeated_init_exec", code) + out, err = self.run_embedded_interpreter("test_repeated_init_exec", code, + env=remove_python_envvars()) self.assertEqual(out, '9\n' * INIT_LOOPS) class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): From d3bff23ba9b6df22327704dbf1a9e9c0ca92a5ac Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Tue, 26 Apr 2022 23:41:55 +0900 Subject: [PATCH 2/2] patch for test_repeated_init_exec --- Lib/test/test_embed.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index e1626708ff1d16..fd474b12a0749a 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -96,6 +96,12 @@ def run_embedded_interpreter(self, *args, env=None, env = env.copy() env['SYSTEMROOT'] = os.environ['SYSTEMROOT'] + if env is None and MS_WINDOWS: + if args[0] == "test_repeated_init_exec": + # PYTHONHOME needs to be removed for an executable in + # a build directory to import *.pyd repeatedly. + env = remove_python_envvars() + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -346,8 +352,7 @@ def test_finalize_structseq(self): def test_ucnhash_capi_reset(self): # bpo-47182: unicodeobject.c:ucnhash_capi was not reset on shutdown. code = "print('\\N{digit nine}')" - out, err = self.run_embedded_interpreter("test_repeated_init_exec", code, - env=remove_python_envvars()) + out, err = self.run_embedded_interpreter("test_repeated_init_exec", code) self.assertEqual(out, '9\n' * INIT_LOOPS) class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):