[Python-checkins] cpython (3.4): make sure the builtin help function doesn't fail when sys.stdin is not a valid
benjamin.peterson
python-checkins at python.org
Sun Jun 8 05:17:44 CEST 2014
http://hg.python.org/cpython/rev/baca52bb5c74
changeset: 91080:baca52bb5c74
branch: 3.4
parent: 91076:ddc174c4c7e5
user: Benjamin Peterson <benjamin at python.org>
date: Sat Jun 07 20:14:26 2014 -0700
summary:
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.
files:
Lib/pydoc.py | 2 ++
Lib/test/test_pydoc.py | 8 ++++++++
Misc/NEWS | 3 +++
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1417,6 +1417,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 --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,9 @@
Library
-------
+- 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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list