[Python-checkins] cpython (3.4): #23792: also catch interrupt around pipe.write.

r.david.murray python-checkins at python.org
Mon Mar 30 16:17:59 CEST 2015


https://hg.python.org/cpython/rev/7a5f30babc72
changeset:   95298:7a5f30babc72
branch:      3.4
parent:      95293:9d3013a383eb
user:        R David Murray <rdmurray at bitdance.com>
date:        Mon Mar 30 10:14:47 2015 -0400
summary:
  #23792: also catch interrupt around pipe.write.

The previous patch only dealt with KeyboardInterrupt when all of the
data had been consumed by the pager.  This deals with the interrupt
when some data is still pending.

files:
  Lib/pydoc.py |  7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1453,7 +1453,12 @@
     proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
     try:
         with io.TextIOWrapper(proc.stdin, errors='backslashreplace') as pipe:
-            pipe.write(text)
+            try:
+                pipe.write(text)
+            except KeyboardInterrupt:
+                # We've hereby abandoned whatever text hasn't been written,
+                # but the pager is still in control of the terminal.
+                pass
     except OSError:
         pass # Ignore broken pipes caused by quitting the pager program.
     while True:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list