changeset: 91082:3bbb8cb45f58 parent: 91079:0fb7789b5eeb parent: 91080:baca52bb5c74 user: Benjamin Peterson date: Sat Jun 07 20:17:29 2014 -0700 files: Lib/pydoc.py Misc/NEWS description: merge 3.4 (#11709) diff -r 0fb7789b5eeb -r 3bbb8cb45f58 Lib/pydoc.py --- a/Lib/pydoc.py Sat Jun 07 20:06:48 2014 -0700 +++ b/Lib/pydoc.py Sat Jun 07 20:17:29 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 0fb7789b5eeb -r 3bbb8cb45f58 Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Sat Jun 07 20:06:48 2014 -0700 +++ b/Lib/test/test_pydoc.py Sat Jun 07 20:17:29 2014 -0700 @@ -446,6 +446,14 @@ result, doc_loc = get_pydoc_text(xml.etree) self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") + def test_getpager_with_stdin_none(self): + previous_stdin = sys.stdin + try: + sys.stdin = None + pydoc.getpager() # Shouldn't fail. + finally: + sys.stdin = previous_stdin + def test_non_str_name(self): # issue14638 # Treat illegal (non-str) name like no name diff -r 0fb7789b5eeb -r 3bbb8cb45f58 Misc/NEWS --- a/Misc/NEWS Sat Jun 07 20:06:48 2014 -0700 +++ b/Misc/NEWS Sat Jun 07 20:17:29 2014 -0700 @@ -94,6 +94,9 @@ - Issue #20578: Add io.BufferedIOBase.readinto1. +- Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a + valid file. + - Issue #21515: tempfile.TemporaryFile now uses os.O_TMPFILE flag is available. - Issue #13223: Fix pydoc.writedoc so that the HTML documentation for methods