Index: Lib/pydoc.py =================================================================== --- Lib/pydoc.py (revision 77420) +++ Lib/pydoc.py (working copy) @@ -53,6 +53,7 @@ # path will be displayed. import sys, imp, os, re, types, inspect, __builtin__, pkgutil +import locale from repr import Repr from string import expandtabs, find, join, lower, split, strip, rfind, rstrip from traceback import extract_tb @@ -1333,7 +1334,8 @@ if sys.platform == 'win32' or sys.platform.startswith('os2'): return lambda text: tempfilepager(plain(text), 'more <') if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0: - return lambda text: pipepager(text, 'less') + encoded_text = text.encode(locale.getpreferredencoding()) + return lambda text: pipepager(encoded_text, 'less') import tempfile (fd, filename) = tempfile.mkstemp() @@ -1348,7 +1350,7 @@ def plain(text): """Remove boldface formatting from text.""" - return re.sub('.\b', '', text) + return re.sub('.\b', '', text).encode(locale.getpreferredencoding()) def pipepager(text, cmd): """Page through text by feeding it to another program.""" @@ -1363,7 +1365,7 @@ """Page through text by invoking a program on a temporary file.""" import tempfile filename = tempfile.mktemp() - file = open(filename, 'w') + file = open(filename, 'wb') file.write(text) file.close() try: Index: Lib/test/test_pydoc.py =================================================================== --- Lib/test/test_pydoc.py (revision 77420) +++ Lib/test/test_pydoc.py (working copy) @@ -15,7 +15,7 @@ from test import pydoc_mod expected_text_pattern = \ -""" +u""" NAME test.pydoc_mod - This is a test module for test_pydoc @@ -55,6 +55,7 @@ hunger lack of Python war + \xfcnicode\u2026 \x20\x20\x20\x20 nodoc_func() @@ -74,7 +75,7 @@ """.strip() expected_html_pattern = \ -""" +u"""
 
@@ -138,7 +139,8 @@
doc_func()
This function solves all of the world's problems:
hunger
lack of Python
-war
+war
+\xfcnicode\u2026
nodoc_func()

Index: Lib/test/pydoc_mod.py =================================================================== --- Lib/test/pydoc_mod.py (revision 77420) +++ Lib/test/pydoc_mod.py (working copy) @@ -16,11 +16,12 @@ pass def doc_func(): - """ + u""" This function solves all of the world's problems: hunger lack of Python war + \xfcnicode\u2026 """ def nodoc_func():