diff options
author | Georg Brandl <georg@python.org> | 2010-07-31 21:51:48 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-07-31 21:51:48 +0000 |
commit | 78aa3964156c97329ca514d1f38bd3fbc2eda8db (patch) | |
tree | 173063e11adf9c2e4cddc0a192fc0a0e50eb9a57 /Lib/pydoc.py | |
parent | bb1901529dd7fa4345b8792fa166415a79494179 (diff) | |
download | cpython-git-78aa3964156c97329ca514d1f38bd3fbc2eda8db.tar.gz |
#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.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 16 |
1 files changed, 12 insertions, 4 deletions
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.""" |