#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.
This commit is contained in:
R David Murray 2015-03-30 10:14:47 -04:00
parent 9aa1331c6f
commit e7f5e147cd
1 changed files with 6 additions and 1 deletions

View File

@ -1453,7 +1453,12 @@ def pipepager(text, cmd):
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
try:
with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
try:
pipe.write(text)
except KeyboardInterrupt:
# We've hereby abandoned whatever text hasn't been written,
# but the pager is still in control of the terminal.
pass
except OSError:
pass # Ignore broken pipes caused by quitting the pager program.
while True: