changeset: 90671:89a29e92416f branch: 3.4 parent: 90669:cee528d44b1e user: Victor Stinner date: Tue May 13 02:05:35 2014 +0200 files: Lib/pydoc.py Misc/NEWS description: Issue #21398: Fix an unicode error in the pydoc pager when the documentation contains characters not encodable to the stdout encoding. diff -r cee528d44b1e -r 89a29e92416f Lib/pydoc.py --- a/Lib/pydoc.py Tue May 13 01:32:36 2014 +0200 +++ b/Lib/pydoc.py Tue May 13 02:05:35 2014 +0200 @@ -1404,6 +1404,9 @@ def pager(text): """The first time this is called, determine what kind of pager to use.""" global pager + # Escape non-encodable characters to avoid encoding errors later + encoding = sys.getfilesystemencoding() + text = text.encode(encoding, 'backslashreplace').decode(encoding) pager = getpager() pager(text) diff -r cee528d44b1e -r 89a29e92416f Misc/NEWS --- a/Misc/NEWS Tue May 13 01:32:36 2014 +0200 +++ b/Misc/NEWS Tue May 13 02:05:35 2014 +0200 @@ -26,6 +26,9 @@ - Issue #21396: Fix TextIOWrapper(..., write_through=True) to not force a flush() on the underlying binary stream. Patch by akira. +- Issue #21398: Fix an unicode error in the pydoc pager when the documentation + contains characters not encodable to the stdout encoding. + Tests -----