]> granicus.if.org Git - python/commitdiff
Issue #22314: pydoc now works when the LINES environment variable is set.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 27 Nov 2014 22:09:29 +0000 (00:09 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 27 Nov 2014 22:09:29 +0000 (00:09 +0200)
Lib/pydoc.py
Misc/NEWS

index bfb0a03378c4d0ecf73c61ee006c5c3979d925c3..d53a1b4b7eb72b40ccc8a7ff58f8f8f28e709851 100755 (executable)
@@ -1479,12 +1479,18 @@ def ttypager(text):
         old = tty.tcgetattr(fd)
         tty.setcbreak(fd)
         getchar = lambda: sys.stdin.read(1)
-    except (ImportError, AttributeError):
+    except (ImportError, AttributeError, io.UnsupportedOperation):
         tty = None
         getchar = lambda: sys.stdin.readline()[:-1][:1]
 
     try:
-        r = inc = os.environ.get('LINES', 25) - 1
+        try:
+            h = int(os.environ.get('LINES', 0))
+        except ValueError:
+            h = 0
+        if h <= 1:
+            h = 25
+        r = inc = h - 1
         sys.stdout.write('\n'.join(lines[:inc]) + '\n')
         while lines[r:]:
             sys.stdout.write('-- more --')
index 7c17a370d4c760ba44d0619c654f6e67ca5821ae..e69f91924c47063182017b5abbbe85c773e7f187 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -184,6 +184,11 @@ Documentation
 - Issue #21514: The documentation of the json module now refers to new JSON RFC
   7159 instead of obsoleted RFC 4627.
 
+Tools/Demos
+-----------
+
+- Issue #22314: pydoc now works when the LINES environment variable is set.
+
 Windows
 -------