From 78aa3964156c97329ca514d1f38bd3fbc2eda8db Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 31 Jul 2010 21:51:48 +0000 Subject: #8198: the Helper class should not save the stdin and stdout objects at import time, rather by default use the current streams like the other APIs that output help. --- Lib/pydoc.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Lib/pydoc.py') diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 95eb3183b7..4f2288710e 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -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.""" -- cgit v1.2.1