Daniel Diniz <[email protected]> added the comment:
Nice buglet, please take a look at Lib/pydoc.py to follow :)
As you point out, this is issue 1700304.
'plainpager', which outputs the help in these cases, uses
'sys.stdout.write(plain(text))', but Helper.help has a
"self.output.write('\n')" line that causes the behavior you see.
We could change "self.output.write('\n')" to "pager('\n')", but the real bug is
that self.output is bound early to sys.stdout. So 'help()' is still redirecting
to the old sys.stdout with your test.
I see a solution by turning Helper.output into a property, but it smells of
over-engineering :) Passing all output to pagers should work too, unless we
need Helper.output as a sort of sys.stderr.
The patch below shows that importing pydoc sets self.output prematurely and
includes the "self.output.write('\n')" line.
Index: pydoc.py
===================================================================
--- pydoc.py (revision 79447)
+++ pydoc.py (working copy)
@@ -1765,6 +1765,7 @@
elif isinstance(request, Helper): self()
else: doc(request, 'Help on %s:')
self.output.write('\n')
+ print >> sys.stderr, repr(self.output)
def intro(self):
self.output.write('''
----------
dependencies: +pydoc.help samples sys.stdout and sys.stdin at import time
keywords: +easy
nosy: +ajaksu2
priority: -> low
stage: -> test needed
type: -> behavior
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8198>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com