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.

Author ajaksu2
Recipients a.badger, ajaksu2, janssen
Date 2009-02-08.21:50:18
SpamBayes Score 0.00014319562
Marked as misclassified No
Message-id <1234129820.99.0.614874558233.issue3991@psf.upfronthosting.co.za>
In-reply-to
Content
I think Toshio's usecase is important enough to deserve a fix (patch
attached) or a special-cased error message. IMO, newbies trying to fix
failures from urlopen may have a hard time figuring out the maze:

urlopen -> _opener -> open -> _open -> _call_chain -> http_open -> 
do_open (and that's before leaving urllib!).

>>> from urllib.request import urlopen
>>> url = 'http://localhost/ñ.html'
>>> urlopen(url).read()
Traceback (most recent call last):
[...]
UnicodeEncodeError: 'ascii' codec can't encode character '\xf1' in
position 5: ordinal not in range(128)


If the newbie isn't completely lost by then, how about:
>>> from urllib.parse import quote
>>> urlopen(quote(url)).read()
Traceback (most recent call last):
[...]
ValueError: unknown url type: http%3A//localhost/%C3%B1.html
History
Date User Action Args
2009-02-08 21:50:21ajaksu2setrecipients: + ajaksu2, janssen, a.badger
2009-02-08 21:50:20ajaksu2setmessageid: <1234129820.99.0.614874558233.issue3991@psf.upfronthosting.co.za>
2009-02-08 21:50:19ajaksu2linkissue3991 messages
2009-02-08 21:50:19ajaksu2create