summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index c92b324..7a625e1 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1450,11 +1450,18 @@ def pipepager(text, cmd):
import subprocess
proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
try:
- with proc:
- with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
- pipe.write(text)
+ with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
+ pipe.write(text)
except OSError:
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):
"""Page through text by invoking a program on a temporary file."""