Merge: #23792: Ignore KeyboardInterrupt when the pydoc pager is active.

This commit is contained in:
R David Murray 2015-03-29 15:19:13 -04:00
commit f375b0a4d5
2 changed files with 14 additions and 3 deletions

View File

@ -1450,11 +1450,18 @@ def pipepager(text, cmd):
import subprocess import subprocess
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE) proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
try: try:
with proc: with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe: pipe.write(text)
pipe.write(text)
except OSError: except OSError:
pass # Ignore broken pipes caused by quitting the pager program. pass # Ignore broken pipes caused by quitting the pager program.
while True:
try:
proc.wait()
break
except KeyboardInterrupt:
# Ignore ctl-c like the pager itself does. Otherwise the pager is
# left running and the terminal is in raw mode and unusable.
pass
def tempfilepager(text, cmd): def tempfilepager(text, cmd):
"""Page through text by invoking a program on a temporary file.""" """Page through text by invoking a program on a temporary file."""

View File

@ -30,6 +30,10 @@ Core and Builtins
Library Library
------- -------
- Issue #23792: Ignore KeyboardInterrupt when the pydoc pager is active.
This mimics the behavior of the standard unix pagers, and prevents
pipepager from shutting down while the pager itself is still running.
- Issue #23775: pprint() of OrderedDict now outputs the same representation - Issue #23775: pprint() of OrderedDict now outputs the same representation
as repr(). as repr().