changeset: 93631:c6182a7e75fa branch: 3.4 parent: 93627:27ae1a476ef7 user: Serhiy Storchaka date: Fri Nov 28 00:09:29 2014 +0200 files: Lib/pydoc.py Misc/NEWS description: Issue #22314: pydoc now works when the LINES environment variable is set. diff -r 27ae1a476ef7 -r c6182a7e75fa Lib/pydoc.py --- a/Lib/pydoc.py Thu Nov 27 22:13:16 2014 +0200 +++ b/Lib/pydoc.py Fri Nov 28 00:09:29 2014 +0200 @@ -1479,12 +1479,18 @@ 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 -r 27ae1a476ef7 -r c6182a7e75fa Misc/NEWS --- a/Misc/NEWS Thu Nov 27 22:13:16 2014 +0200 +++ b/Misc/NEWS Fri Nov 28 00:09:29 2014 +0200 @@ -184,6 +184,11 @@ - 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 -------