diff -r 3f2f1ffc3ce2 Lib/pydoc.py --- a/Lib/pydoc.py Sat Jun 07 17:55:53 2014 -0700 +++ b/Lib/pydoc.py Sat Jun 07 19:56:55 2014 -0700 @@ -1415,6 +1415,8 @@ def getpager(): """Decide what method to use for paging through text.""" + if not hasattr(sys.stdin, "isatty"): + return plainpager if not hasattr(sys.stdout, "isatty"): return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): diff -r 3f2f1ffc3ce2 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Sat Jun 07 17:55:53 2014 -0700 +++ b/Lib/test/test_pydoc.py Sat Jun 07 19:56:55 2014 -0700 @@ -446,6 +446,16 @@ result, doc_loc = get_pydoc_text(xml.etree) self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") + def test_stdin_none(self): + previous_stdin = sys.stdin + try: + sys.stdin = None + pydoc.getpager() + except: + self.fail("help should work regardless of stdin state") + finally: + sys.stdin = previous_stdin + def test_non_str_name(self): # issue14638 # Treat illegal (non-str) name like no name