[3.14] gh-142353: Isolate tests from personal GNU Readline init files (GH-142370) (#142634)

gh-142353: Isolate tests from personal GNU Readline init files (GH-142370)

Isolate tests from personal Readline init files using `INPUTRC=/dev/null` trick.
(cherry picked from commit f564654bae)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2025-12-12 16:08:08 +01:00 committed by GitHub
parent 8e496013b2
commit 5e425c3f96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,14 @@ def run_pty(script, input=b"dummy input\r", env=None):
output = bytearray()
[master, slave] = pty.openpty()
args = (sys.executable, '-c', script)
# Isolate readline from personal init files by setting INPUTRC
# to an empty file. See also GH-142353.
if env is None:
env = {**os.environ.copy(), "INPUTRC": os.devnull}
else:
env.setdefault("INPUTRC", os.devnull)
proc = subprocess.Popen(args, stdin=slave, stdout=slave, stderr=slave, env=env)
os.close(slave)
with ExitStack() as cleanup: