Commit 78aa3964 authored by Georg Brandl's avatar Georg Brandl

#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.
parent bb190152
...@@ -1695,9 +1695,17 @@ class Helper: ...@@ -1695,9 +1695,17 @@ class Helper:
'CONTEXTMANAGERS': ('context-managers', 'with'), 'CONTEXTMANAGERS': ('context-managers', 'with'),
} }
def __init__(self, input, output): def __init__(self, input=None, output=None):
self.input = input self._input = input
self.output = output 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): def __repr__(self):
if inspect.stack()[1][3] == '?': if inspect.stack()[1][3] == '?':
...@@ -1874,7 +1882,7 @@ Enter any module name to get more help. Or, type "modules spam" to search ...@@ -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". for modules whose descriptions contain the word "spam".
''') ''')
help = Helper(sys.stdin, sys.stdout) help = Helper()
class Scanner: class Scanner:
"""A generic tree iterator.""" """A generic tree iterator."""
......
...@@ -15,6 +15,9 @@ Core and Builtins ...@@ -15,6 +15,9 @@ Core and Builtins
Library 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 ``\\.\`` - Issue #7909: Do not touch paths with the special prefixes ``\\.\``
or ``\\?\`` in ntpath.normpath(). or ``\\?\`` in ntpath.normpath().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment