summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLib/pydoc.py2
-rw-r--r--Lib/test/test_pydoc.py8
-rw-r--r--Misc/NEWS3
3 files changed, 13 insertions, 0 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index cb65aef..adb15c4 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1415,6 +1415,8 @@ def pager(text):
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 --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index 188c4c2..542b433 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -446,6 +446,14 @@ class PydocDocTest(unittest.TestCase):
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 --git a/Misc/NEWS b/Misc/NEWS
index 3679df4..70bd160 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -94,6 +94,9 @@ Library
- 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