New submission from Skip Montanaro: I'm probably doing something wrong, but I've tried everything I can think of without any success.
In Python 2.7, the pydoc command successfully displays help for the sqlite3 package, though it muffs the output of Gerhard Häring's name, spitting out the original Latin-1 spelling. In Python 3.x, I get a UnicodeEncodeError for my trouble, and it hoses my tty settings to boot, requiring a LF reset LF sequence to put right unless I set PAGER to "cat". Here's a sample run: % PAGER=cat pydoc3.5 sqlite3 Traceback (most recent call last): File "/Users/skip/local/bin/pydoc3.5", line 5, in <module> pydoc.cli() File "/Users/skip/local/lib/python3.5/pydoc.py", line 2591, in cli help.help(arg) File "/Users/skip/local/lib/python3.5/pydoc.py", line 1874, in help elif request: doc(request, 'Help on %s:', output=self._output) File "/Users/skip/local/lib/python3.5/pydoc.py", line 1612, in doc pager(render_doc(thing, title, forceload)) File "/Users/skip/local/lib/python3.5/pydoc.py", line 1412, in pager pager(text) File "/Users/skip/local/lib/python3.5/pydoc.py", line 1428, in <lambda> return lambda text: pipepager(text, os.environ['PAGER']) File "/Users/skip/local/lib/python3.5/pydoc.py", line 1455, in pipepager pipe.write(text) UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 600: ordinal not in range(128) I understand the error, but I see no way to convince it to use any codec other than "ascii". Stuff I tried: * setting PYTHONIOENCODING to "UTF-8" (suggested by Peter Otten on c.l.py) * setting LANG to "en_US.utf8" This is on a Mac running Yosemite with pydoc invoked in Apple's Terminal app. Display is fine in my browser when I run pydoc as a web server. The source it is attempting to display has a coding cookie, so it should know that the code is encoded using Latin-1. The problem seems to all be about generating output. ---------- components: Library (Lib) messages: 235200 nosy: skip.montanaro priority: normal severity: normal status: open title: pydoc 3.x raises UnicodeEncodeError on sqlite3 package type: crash versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23374> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com