Skip to content

Commit c156e51

Browse files
committed
Merge: #23792: also catch interrupt around pipe.write.
2 parents 93692bb + e7f5e14 commit c156e51

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎Lib/pydoc.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,12 @@ def pipepager(text, cmd):
14511451
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
14521452
try:
14531453
with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
1454-
pipe.write(text)
1454+
try:
1455+
pipe.write(text)
1456+
except KeyboardInterrupt:
1457+
# We've hereby abandoned whatever text hasn't been written,
1458+
# but the pager is still in control of the terminal.
1459+
pass
14551460
except OSError:
14561461
pass # Ignore broken pipes caused by quitting the pager program.
14571462
while True:

0 commit comments

Comments
 (0)