urlib.quote gives KeyError in Python 2.4.4 but workin 2.3.5

N

nyenyec

urllib.quote chokes on unicode in 2.4.4.
2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)]Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/urllib.py",
line 1117, in quote
res = map(safe_map.__getitem__, s)
KeyError: u'\xe9'

but it seems to work in Python 2.3.5

Python 2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)]'%E9'

Is this a known bug?

What's the workaround?

Thanks,
nyenyec
 
N

nyenyec

encode seems to solve my problem:
'%C3%A9'

Cheers,
nyenyec
urllib.quote chokes on unicode in 2.4.4.
2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)]Traceback (most recent call last):
File "<stdin>", line 1, in ?
File
"/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/urllib.py",
line 1117, in quote
res = map(safe_map.__getitem__, s)
KeyError: u'\xe9'

but it seems to work in Python 2.3.5

Python 2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)]'%E9'

Is this a known bug?

What's the workaround?

Thanks,
nyenyec
 
G

Gabriel Genellina

urllib.quote chokes on unicode in 2.4.4.
KeyError: u'\xe9'

but it seems to work in Python 2.3.5

Is this a known bug?

See some recent posts about "urllib.unquote and unicode"
 
D

Duncan Booth

nyenyec said:
but it seems to work in Python 2.3.5

Python 2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.2.3.5 (#1, Aug 19 2006, 21:31:42)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)]'%E9'

'seems to' is correct: it should *probably* have given you '%C3%E9'.
Is this a known bug?

What's the workaround?

UTF-8 encode the url before quoting it.

*Some* web servers may not expect utf-8 encoding. utf-8 is the recommended
encoding, but unfortunately it isn't actually required, so a few (mostly
old) servers may expect something else. If so, use the appropriate encoding
for the server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top