I use OSX 10.9 on my laptop, Python 3.5 and I get this error in one case. If I use CTRL-C to quit the application and if LC_CTYPE=C.
with the 'q' key, I don't get this problem.
Just LC_CTYPE=C and CTRL-C and I have to reset my terminal.

I can also confirm the need to reset the terminal when using
a working locale and Ctrl-C.
So we have two issues then:
1) The UnicodeDecodeError should not happen.
2) pydoc behaves erratically after various exceptions.
In Python2.7 neither of the issues is present.

heapq documentation contains "François" which is not encodable to ASCII. When using LC_ALL=C, the locale encoding is ASCII (at least on Linux). It's not easy to specify a different error handler globally in pydoc, different functions are used and child processes are spawned. The subprocess module doesn't allow to specify an error handler different than strict (see #6135).
I propose pydoc_encoding.patch which escapes manually non-encodable characters. I chose sys.getfilesystemencoding(), I'm not sure that it's the encoding used for all cases of getpager() on all platforms. For example, on Windows, sys.getfilesystemencoding() is the ANSI code page, whereas sys.stdout.encoding is the OEM code page.

"LC_CTYPE=C: pydoc leaves terminal in an unusable state"
In the use case, pydoc doesn't touch the terminal, it's the pager: the program "less". I don't see how to ensure that the terminal state is restored, even on error.

STINNER Victor <report@bugs.python.org> wrote:
> I don't see how to ensure that the terminal state is restored, even on error.
Python2 suppresses the exception until after normal exit (pressing 'q').
I think that behavior is better.
In Python3 you can also get the unusable terminal by pressing Ctrl-C,
i.e. without any UnicodeError.

I fixed the initial bug and so I close the issue.
Open a new issue if you have an idea to restore the terminal state when the pager breaks the terminal. I don't think that it's possible to save/restore the terminal state in a portable way.