Skip to content

Commit e7f5e14

Browse files
committed
#23792: also catch interrupt around pipe.write.
The previous patch only dealt with KeyboardInterrupt when all of the data had been consumed by the pager. This deals with the interrupt when some data is still pending.
1 parent 9aa1331 commit e7f5e14

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
@@ -1453,7 +1453,12 @@ def pipepager(text, cmd):
14531453
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
14541454
try:
14551455
with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
1456-
pipe.write(text)
1456+
try:
1457+
pipe.write(text)
1458+
except KeyboardInterrupt:
1459+
# We've hereby abandoned whatever text hasn't been written,
1460+
# but the pager is still in control of the terminal.
1461+
pass
14571462
except OSError:
14581463
pass # Ignore broken pipes caused by quitting the pager program.
14591464
while True:

0 commit comments

Comments
 (0)