classification
Title: help(urllib.parse) fails when LANG=C
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: eric.araujo, haypo, orsenthil, python-dev, r.david.murray, timeless, tt
Priority: normal Keywords:

Created on 2012-05-25 20:14 by tt, last changed 2012-06-25 06:17 by eric.araujo. This issue is now closed.

Messages (7)
msg161618 - (view) Author: Tuukka Tolvanen (tt) Date: 2012-05-25 20:14
LANG=C python3.2 -c 'import urllib.parse; help(urllib.parse)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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 <lambda>
    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
msg161620 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-05-25 20:21
This works fine for me on Gentoo Linux with both 3.2.3+ (ie: what's in the repo) and 3.2.2.
msg161621 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-05-25 20:21
Ah, I should clarify: Gentoo's 3.2.2.  I'm sure they've added some patches, just like Debian.
msg161625 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-05-25 21:39
Serhiy: did you add 3.3 because you can reproduce it on 3.3?
msg161633 - (view) Author: Roundup Robot (python-dev) Date: 2012-05-26 01:55
New changeset ea25ce432343 by Senthil Kumaran in branch '3.2':
Issue #14920: Fix the help(urllib.parse) failure on locale C terminals. Just have ascii in help msg
http://hg.python.org/cpython/rev/ea25ce432343

New changeset cb62c958dd6a by Senthil Kumaran in branch 'default':
Issue #14920: Fix the help(urllib.parse) failure on locale C terminals. Just have ascii in help msg
http://hg.python.org/cpython/rev/cb62c958dd6a
msg161635 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2012-05-26 02:01
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.
msg163903 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-06-25 06:17
IMO the right fix would have been to make the docstring a raw string.
History
Date User Action Args
2012-06-25 06:17:14eric.araujosetnosy: + eric.araujo
messages: + msg163903
2012-05-28 21:19:23hayposetnosy: + haypo
2012-05-26 02:01:42orsenthilsetstatus: open -> closed

assignee: orsenthil

nosy: + orsenthil
messages: + msg161635
resolution: fixed
stage: resolved
2012-05-26 01:55:45python-devsetnosy: + python-dev
messages: + msg161633
2012-05-25 21:39:34r.david.murraysetmessages: + msg161625
components: + Library (Lib), - None
2012-05-25 20:42:57serhiy.storchakasetversions: + Python 3.3
2012-05-25 20:21:45r.david.murraysetmessages: + msg161621
2012-05-25 20:21:00r.david.murraysetnosy: + r.david.murray
messages: + msg161620
2012-05-25 20:14:22ttcreate