changeset: 93630:50808dffd0bb branch: 2.7 user: Serhiy Storchaka date: Fri Nov 28 00:09:05 2014 +0200 files: Lib/pydoc.py Misc/NEWS description: Issue #22314: pydoc now works when the LINES environment variable is set. diff -r ac7f3161aa53 -r 50808dffd0bb Lib/pydoc.py --- a/Lib/pydoc.py Thu Nov 27 23:45:37 2014 +0200 +++ b/Lib/pydoc.py Fri Nov 28 00:09:05 2014 +0200 @@ -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 -r ac7f3161aa53 -r 50808dffd0bb Misc/NEWS --- a/Misc/NEWS Thu Nov 27 23:45:37 2014 +0200 +++ b/Misc/NEWS Fri Nov 28 00:09:05 2014 +0200 @@ -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.