Skip to content
Browse files

Handle case where input tag / pair is not a str

  • Loading branch information...
1 parent 2718d8a commit ace37c16bbefd312c9d2e80796d9e2c139643c63 @harryf committed Feb 13, 2009
Showing with 3 additions and 4 deletions.
  1. +3 −4 dammit/request.py
View
7 dammit/request.py
@@ -57,6 +57,8 @@ def decode_string(s):
try:
s = s.decode('utf-8')
except:
+ if not type(s) in (str, unicode):
+ s = unicode(s)
s = unicode(non_ascii_pattern.sub('', s))
return urldecode(s)
@@ -85,10 +87,7 @@ def unpack_pairs(s):
for k, v in us.items():
if not is_scalar(k) or not is_scalar(v):
continue
- try:
- out[decode_string(k)] = decode_string(v)
- except:
- out[k] = v
+ out[decode_string(k)] = decode_string(v)
return out

0 comments on commit ace37c1

Please sign in to comment.
Something went wrong with that request. Please try again.