[Python-checkins] cpython (merge 3.4 -> default): Merge: #23792: Ignore KeyboardInterrupt when the pydoc pager is active.

r.david.murray python-checkins at python.org
Sun Mar 29 21:20:13 CEST 2015


https://hg.python.org/cpython/rev/fe0c830b43bb
changeset: 95248:fe0c830b43bb
parent: 95246:c48637f57e2b
parent: 95247:77c04e949b4b
user: R David Murray <rdmurray at bitdance.com>
date: Sun Mar 29 15:19:13 2015 -0400
summary:
 Merge: #23792: Ignore KeyboardInterrupt when the pydoc pager is active.
files:
 Lib/pydoc.py | 13 ++++++++++---
 Misc/NEWS | 4 ++++
 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1450,11 +1450,18 @@
 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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,10 @@
 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().
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /