Message159160
| Author |
taschini |
| Recipients |
cben, loewis, ness, ping, r.david.murray, rhettinger, taschini |
| Date |
2012年04月24日.15:26:41 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1335281202.59.0.557202642342.issue1065986@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Oh well, in that case I guess we'll have to work around it.
Here's the monkey patch I use to overcome this limitation in pydoc, in case others wish to add it to their PYTHONSTARTUP or sitecustomize:
def pipepager(text, cmd):
"""Page through text by feeding it to another program."""
try:
import locale
except ImportError:
encoding = "ascii"
else:
encoding = locale.getpreferredencoding()
pipe = os.popen(cmd, 'w')
try:
pipe.write(text.encode(encoding, 'xmlcharrefreplace') if isinstance(text, unicode) else text)
pipe.close()
except IOError:
pass # Ignore broken pipes caused by quitting the pager program.
import pydoc
pydoc.pipepager = pipepager
del pydoc, pipepager |
|