From 46e92503dab0311b4d000747b8a6f2d2a68e39ad Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 28 Nov 2014 00:09:05 +0200 Subject: [PATCH] Issue #22314: pydoc now works when the LINES environment variable is set. --- Lib/pydoc.py | 8 +++++++- Misc/NEWS | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 594e6c789e3..0647d1e8ffe 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1446,7 +1446,13 @@ def ttypager(text): 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 index d3bf2dedc94..642ada04986 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -25,6 +25,8 @@ Documentation 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.