This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2012-05-25 20:14 by tt, last changed 2022-04-11 14:57 by admin. 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/", line 477, in __call__
    return*args, **kwds)
  File "/usr/lib/python3.2/", line 1778, in __call__
  File "/usr/lib/python3.2/", line 1828, in help
    else: doc(request, 'Help on %s:', output=self._output)
  File "/usr/lib/python3.2/", line 1564, in doc
    pager(render_doc(thing, title, forceload))
  File "/usr/lib/python3.2/", line 1372, in pager
  File "/usr/lib/python3.2/", line 1392, in <lambda>
    return lambda text: pipepager(text, 'less')
  File "/usr/lib/python3.2/", line 1413, in pipepager
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) (Python triager) 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

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
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.


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.
Date User Action Args
2022-04-11 14:57:30adminsetgithub: 59125
2012-06-25 06:17:14eric.araujosetnosy: + eric.araujo
messages: + msg163903
2012-05-28 21:19:23vstinnersetnosy: + vstinner
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