diff -r 9df126ee7005 Lib/pydoc.py --- a/Lib/pydoc.py Sun Jun 01 15:28:11 2014 -0700 +++ b/Lib/pydoc.py Sat Jun 07 14:44:32 2014 -0700 @@ -1410,6 +1410,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 9df126ee7005 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Sun Jun 01 15:28:11 2014 -0700 +++ b/Lib/test/test_pydoc.py Sat Jun 07 14:44:32 2014 -0700 @@ -402,6 +402,28 @@ result, doc_loc = get_pydoc_text(xml.etree) self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") + def test_stdin_none(self): + # change environment for this test case + previous_stdin = sys.stdin + try: + # assume stdin is not set to none (confirmed default) + with captured_output('stdout') as output: + help(1) + expected_output = output.getvalue() + + # with stdin set to None + sys.stdin = None + with captured_output('stdout') as output: + help(1) + actual_output = output.getvalue() + + if actual_output != expected_output: + self.fail("help should work regardless of stdin state") + + # restore environment + finally: + sys.stdin = previous_stdin + def test_non_str_name(self): # issue14638 # Treat illegal (non-str) name like no name