summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2015-03-29 19:19:13 (GMT)
committerR David Murray <rdmurray@bitdance.com>2015-03-29 19:19:13 (GMT)
commitf375b0a4d5a0362ca9b927e626a00c8328f3ac04 (patch)
treefb476a8fb3a3b4bcabb5aabc925b869067725fda
parent1b74d630da388ace3187101c821d55b0799580d4 (diff)
parent1058cda38f1b409c4d52eef236f4915df592a112 (diff)
downloadcpython-f375b0a4d5a0362ca9b927e626a00c8328f3ac04.zip
cpython-f375b0a4d5a0362ca9b927e626a00c8328f3ac04.tar.gz
cpython-f375b0a4d5a0362ca9b927e626a00c8328f3ac04.tar.bz2
Merge: #23792: Ignore KeyboardInterrupt when the pydoc pager is active.
-rwxr-xr-xLib/pydoc.py13
-rw-r--r--Misc/NEWS4
2 files changed, 14 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."""
diff --git a/Misc/NEWS b/Misc/NEWS
index 5fa6b72..6402617 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,10 @@ Core and Builtins
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
as repr().