summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-27 22:09:29 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-27 22:09:29 (GMT)
commitab5e9b9213558d00ef8405d89e4cb103795972e3 (patch)
tree01c571ee7f96fa5bfcf8201b75bb6bcad2b69620
parentfc8e9b0e726c14d10cf33864710364b3cb4ae368 (diff)
downloadcpython-ab5e9b9213558d00ef8405d89e4cb103795972e3.zip
cpython-ab5e9b9213558d00ef8405d89e4cb103795972e3.tar.gz
cpython-ab5e9b9213558d00ef8405d89e4cb103795972e3.tar.bz2
Issue #22314: pydoc now works when the LINES environment variable is set.
-rwxr-xr-xLib/pydoc.py10
-rw-r--r--Misc/NEWS5
2 files changed, 13 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index bfb0a03..d53a1b4 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -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 --')
diff --git a/Misc/NEWS b/Misc/NEWS
index 7c17a37..e69f919 100644
--- 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
-------