[Python-checkins] cpython (2.7): Issue #22314: pydoc now works when the LINES environment variable is set.

serhiy.storchaka python-checkins at python.org
Thu Nov 27 23:15:45 CET 2014


https://hg.python.org/cpython/rev/50808dffd0bb
changeset:   93630:50808dffd0bb
branch:      2.7
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Nov 28 00:09:05 2014 +0200
summary:
  Issue #22314: pydoc now works when the LINES environment variable is set.

files:
  Lib/pydoc.py |  8 +++++++-
  Misc/NEWS    |  2 ++
  2 files changed, 9 insertions(+), 1 deletions(-)


diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1446,7 +1446,13 @@
         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(join(lines[:inc], '\n') + '\n')
         while lines[r:]:
             sys.stdout.write('-- more --')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,8 @@
 Tools/Demos
 -----------
 
+- Issue #22314: pydoc now works when the LINES environment variable is set.
+
 - Issue #18905: "pydoc -p 0" now outputs actually used port.  Based on patch by
   Wieland Hoffmann.
 

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


More information about the Python-checkins mailing list