aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pyrepl/test_pyrepl.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-10-08 15:48:40 +0200
committerGitHub <noreply@github.com>2024-10-08 15:48:40 +0200
commit65ce228d63878d8b6d0005f682e89ad9d5289c4b (patch)
tree64589c787d33f19485b60e9c4b5bdec9416e0c6b /Lib/test/test_pyrepl/test_pyrepl.py
parent5967dd8a4de60a418de84d1d1d9efc063ad12c47 (diff)
downloadcpython-65ce228d63878d8b6d0005f682e89ad9d5289c4b.tar.gz
cpython-65ce228d63878d8b6d0005f682e89ad9d5289c4b.zip
gh-125096: Don't import _pyrepl in site if PYTHON_BASIC_REPL (#125097)
If the PYTHON_BASIC_REPL environment variable is set, the site module no longer imports the _pyrepl module. Moreover, the site module now respects -E and -I command line options: ignore PYTHON_BASIC_REPL in this case.
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 36f940eaea4..1a76832386b 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -1204,6 +1204,18 @@ class TestMain(ReplTestCase):
self.assertNotIn("Exception", output)
self.assertNotIn("Traceback", output)
+ # The site module must not load _pyrepl if PYTHON_BASIC_REPL is set
+ commands = ("import sys\n"
+ "print('_pyrepl' in sys.modules)\n"
+ "exit()\n")
+ env["PYTHON_BASIC_REPL"] = "1"
+ output, exit_code = self.run_repl(commands, env=env)
+ self.assertEqual(exit_code, 0)
+ self.assertIn("False", output)
+ self.assertNotIn("True", output)
+ self.assertNotIn("Exception", output)
+ self.assertNotIn("Traceback", output)
+
@force_not_colorized
def test_bad_sys_excepthook_doesnt_crash_pyrepl(self):
env = os.environ.copy()