1. Nick Coghlan
  2. cpython_sandbox


Benjamin Peterson  committed baca52b

make sure the builtin help function doesn't fail when sys.stdin is not a valid file (closes #11709)

Original patch by Amaury Forgeot d'Arc with a test by bdettmer.

  • Participants
  • Parent commits ddc174c
  • Branches 3.4

Comments (0)

Files changed (3)

File Lib/pydoc.py

View file
  • Ignore whitespace
 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():

File Lib/test/test_pydoc.py

View file
  • Ignore whitespace
         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

File Misc/NEWS

View file
  • Ignore whitespace
+- Issue #11709: Fix the pydoc.help function to not fail when sys.stdin is not a
+  valid file.
 - Issue #13223: Fix pydoc.writedoc so that the HTML documentation for methods
   that use 'self' in the example code is generated correctly.