Issue 14920: help(urllib.parse) fails when LANG=C (original) (raw)
LANG=C python3.2 -c 'import urllib.parse; help(urllib.parse)' Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.2/site.py", line 477, in call return pydoc.help(*args, **kwds) File "/usr/lib/python3.2/pydoc.py", line 1778, in call self.help(request) File "/usr/lib/python3.2/pydoc.py", line 1828, in help else: doc(request, 'Help on %s:', output=self._output) File "/usr/lib/python3.2/pydoc.py", line 1564, in doc pager(render_doc(thing, title, forceload)) File "/usr/lib/python3.2/pydoc.py", line 1372, in pager pager(text) File "/usr/lib/python3.2/pydoc.py", line 1392, in return lambda text: pipepager(text, 'less') File "/usr/lib/python3.2/pydoc.py", line 1413, in pipepager pipe.write(text) UnicodeEncodeError: 'ascii' codec can't encode character '\xab' in position 5495: ordinal not in range(128)
presumably the offending part is quote_from_bytes(b'abc def«') -> 'abc%20def%AB'
debian python3.2 3.2.3~rc2-1 macports python32 @3.2.3_0
I have fixed the help to include only ascii characters ( represented in hex) so that conversion to bytes is represented in the help and also the terminal whose LANG is C is able to display them too.
On Ubuntu, when I had LANG=C, locale gave the following o/p and the previous help, (which broke for the Tuukka Tolvanen) was working fine too.
LANG=C LANGUAGE=en_US:en LC_CTYPE=en_US.UTF-8 LC_NUMERIC="C" LC_TIME="C" LC_COLLATE=en_US.UTF-8 LC_MONETARY="C" LC_MESSAGES=en_US.UTF-8 LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL=
I guess, the original bug could be related to settings differing on gentoo. Anyways, the help docstring is changed now.