diff -r 1855b5c3da61 Lib/pydoc.py --- a/Lib/pydoc.py Mon Nov 17 23:48:35 2014 +0200 +++ b/Lib/pydoc.py Tue Nov 18 11:41:50 2014 +0200 @@ -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', 25)) + if h <= 1: + h = 25 + except ValueError: + h = 25 + r = inc = h - 1 sys.stdout.write('\n'.join(lines[:inc]) + '\n') while lines[r:]: sys.stdout.write('-- more --')