This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ajaksu2
Recipients ajaksu2, farialima
Date 2010-03-31.06:14:30
SpamBayes Score 2.8410122e-07
Marked as misclassified No
Message-id <1270016073.18.0.806961616916.issue8198@psf.upfronthosting.co.za>
In-reply-to
Content
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('''
History
Date User Action Args
2010-03-31 06:14:33ajaksu2setrecipients: + ajaksu2, farialima
2010-03-31 06:14:33ajaksu2setmessageid: <1270016073.18.0.806961616916.issue8198@psf.upfronthosting.co.za>
2010-03-31 06:14:31ajaksu2linkissue8198 messages
2010-03-31 06:14:30ajaksu2create