summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorEnrico Tröger <enrico.troeger@uvena.de>2024-06-08 09:19:13 (GMT)
committerGitHub <noreply@github.com>2024-06-08 09:19:13 (GMT)
commit2080425154d235b4b7dcc9a8a2f58e71769125ca (patch)
tree385fc4fdcae8ecd448f9b43f3793d574e4af4498 /Lib/pydoc.py
parent95f4db88d5ab7d900f05d0418b2a2e77bf9ff126 (diff)
downloadcpython-2080425154d235b4b7dcc9a8a2f58e71769125ca.zip
cpython-2080425154d235b4b7dcc9a8a2f58e71769125ca.tar.gz
cpython-2080425154d235b4b7dcc9a8a2f58e71769125ca.tar.bz2
bpo-37755: Use configured output in pydoc instead of pager (GH-15105)
If the Helper() class was initialized with an output, the topics, keywords and symbols help still use the pager instead of the output. Change the behavior so the output is used if available while keeping the previous behavior if no output was configured.
Diffstat (limited to 'Lib/pydoc.py')
-rw-r--r--Lib/pydoc.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 2ba597d..d7579c1 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -2034,7 +2034,7 @@ has the same effect as typing a particular string at the help> prompt.
elif request in self.symbols: self.showsymbol(request)
elif request in ['True', 'False', 'None']:
# special case these keywords since they are objects too
- doc(eval(request), 'Help on %s:', is_cli=is_cli)
+ doc(eval(request), 'Help on %s:', output=self._output, is_cli=is_cli)
elif request in self.keywords: self.showtopic(request)
elif request in self.topics: self.showtopic(request)
elif request: doc(request, 'Help on %s:', output=self._output, is_cli=is_cli)
@@ -2127,7 +2127,11 @@ module "pydoc_data.topics" could not be found.
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
wrapped_text = textwrap.wrap(text, 72)
doc += '\n%s\n' % '\n'.join(wrapped_text)
- pager(doc, f'Help on {topic!s}')
+
+ if self._output is None:
+ pager(doc, f'Help on {topic!s}')
+ else:
+ self.output.write(doc)
def _gettopic(self, topic, more_xrefs=''):
"""Return unbuffered tuple of (topic, xrefs).