cpython: 77c04e949b4b (original) (raw)

Mercurial > cpython

changeset 95247:77c04e949b4b 3.4

#23792: Ignore KeyboardInterrupt when the pydoc pager is active. Previously, if you hit ctl-c while the pager was active, the python that launched the subprocess for the pager would see the KeyboardInterrupt in the __exit__ method of the subprocess context manager where it was waiting for the subprocess to complete, ending the wait. This would leave the pager running, while the interactive interpreter, after handling the exception by printing it, would go back to trying to post a prompt...but the pager would generally have the terminal in raw mode, and in any case would be still trying to read from stdin. On some systems, even exiting python at that point would not restore the terminal mode. The problem with raw mode could also happen if ctl-C was hit when pydoc was called from the shell command line and the pager was active. Instead, we now wait on the subprocess in a loop, ignoring KeyboardInterrupt just like the pager does, until the pager actually exits. (Note: this was a regression relative to python2...in python2 the pager is called via system, and system does not return until the pager exits.) [#23792]

R David Murray rdmurray@bitdance.com
date Sun, 29 Mar 2015 15:15:40 -0400
parents c23713af8be7
children fe0c830b43bb 3af77d1c5c47
files Lib/pydoc.py Misc/NEWS
diffstat 2 files changed, 14 insertions(+), 3 deletions(-)[+] [-] Lib/pydoc.py 13 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1452,11 +1452,18 @@ def pipepager(text, cmd): import subprocess proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE) try:

def tempfilepager(text, cmd): """Page through text by invoking a program on a temporary file."""

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -21,6 +21,10 @@ Core and Builtins Library ------- +- Issue #23792: Ignore KeyboardInterrupt when the pydoc pager is active.