From 97bec8ecf213e065f1da2e1f783c99abbb1a4332 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Tue, 19 May 2026 08:03:08 -0700 Subject: [PATCH 1/4] Pass `-E` to subprocesses from `check_add_python_opts` Avoid the runtime environment from affecting the tests' behaviours, which notably checks the warning filters which can be controlled by various environment variables. --- Lib/test/test_regrtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 02f6e0c74b5ce84..45c052425376325 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -2277,7 +2277,7 @@ def test_python_opts(self): # Use directly subprocess to control the exact command line cmd = [sys.executable, - "-m", "test", option, + "-E", "-m", "test", option, f'--testdir={self.tmptestdir}', testname] proc = subprocess.run(cmd, From fb82f0c7c2bdc09cd0b58d12288bfb60045d8cac Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Tue, 19 May 2026 08:10:31 -0700 Subject: [PATCH 2/4] Add blurb --- .../next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst diff --git a/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst b/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst new file mode 100644 index 000000000000000..b322922e1086904 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst @@ -0,0 +1 @@ +Avoid ``PYTHON*`` environment variables affecting regrtest's own tests. From 6fd79779e11ca29eac78f8d70d5073085fef4049 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 21 May 2026 21:52:50 +0100 Subject: [PATCH 3/4] Revert "Add blurb" This reverts commit fb82f0c7c2bdc09cd0b58d12288bfb60045d8cac. --- .../next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst diff --git a/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst b/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst deleted file mode 100644 index b322922e1086904..000000000000000 --- a/Misc/NEWS.d/next/Tests/2026-05-19-08-10-20.gh-issue-150046.MndDD8.rst +++ /dev/null @@ -1 +0,0 @@ -Avoid ``PYTHON*`` environment variables affecting regrtest's own tests. From f92f39ff8e663be34a02891be15caf4c7b0b7d4c Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 21 May 2026 21:53:57 +0100 Subject: [PATCH 4/4] Use support.make_clean_env() instead of `-E` --- Lib/test/test_regrtest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 45c052425376325..874c6bb76b1afe5 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -2277,13 +2277,14 @@ def test_python_opts(self): # Use directly subprocess to control the exact command line cmd = [sys.executable, - "-E", "-m", "test", option, + "-m", "test", option, f'--testdir={self.tmptestdir}', testname] proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - text=True) + text=True, + env=support.make_clean_env()) self.assertEqual(proc.returncode, 0, proc) def test_add_python_opts(self):