]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#8198: the Helper class should not save the stdin and stdout objects
authorGeorg Brandl <georg@python.org>
Sat, 31 Jul 2010 21:51:48 +0000 (21:51 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 31 Jul 2010 21:51:48 +0000 (21:51 +0000)
at import time, rather by default use the current streams like the
other APIs that output help.

Lib/pydoc.py
Misc/NEWS

index 95eb3183b7859e18c31d98771a03006507bc2d9f..4f2288710e43f1a874bcf59b26a77e07136d8b36 100755 (executable)
@@ -1695,9 +1695,17 @@ class Helper:
         'CONTEXTMANAGERS': ('context-managers', 'with'),
     }
 
-    def __init__(self, input, output):
-        self.input = input
-        self.output = output
+    def __init__(self, input=None, output=None):
+        self._input = input
+        self._output = output
+
+    @property
+    def input(self):
+        return self._input or sys.stdin
+
+    @property
+    def output(self):
+        return self._output or sys.stdout
 
     def __repr__(self):
         if inspect.stack()[1][3] == '?':
@@ -1874,7 +1882,7 @@ Enter any module name to get more help.  Or, type "modules spam" to search
 for modules whose descriptions contain the word "spam".
 ''')
 
-help = Helper(sys.stdin, sys.stdout)
+help = Helper()
 
 class Scanner:
     """A generic tree iterator."""
index 5c3275f1c8a304e96757d426221d01de1de49ba3..6d63ae98580c6906a3494c50808af0dbfc70f1e6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #8198: In pydoc, output all help text to the correct stream
+  when sys.stdout is reassigned.
+
 - Issue #7909: Do not touch paths with the special prefixes ``\\.\``
   or ``\\?\`` in ntpath.normpath().