gh-121359: Run test_pyrepl in isolated mode (GH-121414)
run_repl() now pass the -I option (isolated mode) to Python if the
'env' parameter is not set.
(cherry picked from commit
6239d41527d5977aa5d44e4b894d719bc045860e)
Co-authored-by: Victor Stinner <vstinner@python.org>
def run_repl(self, repl_input: str | list[str], env: dict | None = None) -> tuple[str, int]:
master_fd, slave_fd = pty.openpty()
+ cmd = [sys.executable, "-i", "-u"]
+ if env is None:
+ cmd.append("-I")
process = subprocess.Popen(
- [sys.executable, "-i", "-u"],
+ cmd,
stdin=slave_fd,
stdout=slave_fd,
stderr=slave_fd,