diff options
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/pydoc.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index bfb0a03..d53a1b4 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1479,12 +1479,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 --') |