Skip to content

Commit 0bb4ee6

Browse files
authored
Use configured output in pydoc instead of pager
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.
1 parent 18b711c commit 0bb4ee6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ def help(self, request):
19591959
elif request in self.symbols: self.showsymbol(request)
19601960
elif request in ['True', 'False', 'None']:
19611961
# special case these keywords since they are objects too
1962-
doc(eval(request), 'Help on %s:')
1962+
doc(eval(request), 'Help on %s:', output=self._output)
19631963
elif request in self.keywords: self.showtopic(request)
19641964
elif request in self.topics: self.showtopic(request)
19651965
elif request: doc(request, 'Help on %s:', output=self._output)
@@ -2050,7 +2050,7 @@ def showtopic(self, topic, more_xrefs=''):
20502050
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
20512051
wrapped_text = textwrap.wrap(text, 72)
20522052
doc += '\n%s\n' % '\n'.join(wrapped_text)
2053-
pager(doc)
2053+
self.output.write(doc)
20542054

20552055
def _gettopic(self, topic, more_xrefs=''):
20562056
"""Return unbuffered tuple of (topic, xrefs).

0 commit comments

Comments
 (0)