Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Lib/test/support/pty_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@

from test.support.import_helper import import_module

def run_pty(script, input=b"dummy input\r", env=None):
def run_pty(script, input=b"dummy input\r", env=None, readline=None):
pty = import_module('pty')
output = bytearray()
[master, slave] = pty.openpty()
args = (sys.executable, '-c', script)

if readline is None:
readline = "readline" in sys.modules
if readline:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't complicate this by checking whether the backend is editline first.
If we find any reliable way to isolate from libedit, we could simply inline it in this block.

# 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:
Expand Down
Loading