summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-27 22:11:07 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-27 22:11:07 (GMT)
commitf1fc9fb33d6e3181fde24d9fc1a5a224fda5c2ef (patch)
tree71fee2a34219d0c2d75b6b285978fb19db1bda8d /Lib/pydoc.py
parent5916d5303273c9b7f8918b0776ea0f7467e7cebd (diff)
parentab5e9b9213558d00ef8405d89e4cb103795972e3 (diff)
downloadcpython-f1fc9fb33d6e3181fde24d9fc1a5a224fda5c2ef.zip
cpython-f1fc9fb33d6e3181fde24d9fc1a5a224fda5c2ef.tar.gz
cpython-f1fc9fb33d6e3181fde24d9fc1a5a224fda5c2ef.tar.bz2
Issue #22314: pydoc now works when the LINES environment variable is set.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 11451e8..60b0a9e5 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1477,12 +1477,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 --')