diff options
author | R David Murray <rdmurray@bitdance.com> | 2015-03-30 14:14:47 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2015-03-30 14:14:47 (GMT) |
commit | e7f5e147cdc32e7660586ce29ca97ccfe14c97f5 (patch) | |
tree | 93fe9bf9cbacc3746aadcf9505f45683e8957063 /Lib/pydoc.py | |
parent | 9aa1331c6f73b0868f736a40445cc3bcd33c5345 (diff) | |
download | cpython-e7f5e147cdc32e7660586ce29ca97ccfe14c97f5.zip cpython-e7f5e147cdc32e7660586ce29ca97ccfe14c97f5.tar.gz cpython-e7f5e147cdc32e7660586ce29ca97ccfe14c97f5.tar.bz2 |
#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.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index cf9e0f0..faaa859 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -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: - pipe.write(text) + 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: |