Permalink
Browse files

simplyfing parse_utf8_qsl; updating to v0.4.9

  • Loading branch information...
1 parent e78db78 commit 098e9e37941e114618b0314b5dc37821cbb14499 @maxcountryman maxcountryman committed Jun 11, 2012
Showing with 9 additions and 10 deletions.
  1. +1 −1 rauth/__init__.py
  2. +8 −9 rauth/service.py
View
@@ -6,4 +6,4 @@
'''
-__version__ = '0.4.8'
+__version__ = '0.4.9'
View
@@ -20,15 +20,14 @@ def parse_utf8_qsl(s):
d = dict(parse_qsl(s))
for k, v in d.items():
- if isinstance(k, unicode):
- k = k.encode('utf-8')
- else:
- k = unicode(k, 'utf-8').encode('utf-8')
- if isinstance(v, unicode):
- v = v.encode('utf-8')
- else:
- v = unicode(v, 'utf-8').encode('utf-8')
- d[k.decode('utf-8')] = v.decode('utf-8')
+ if isinstance(k, unicode) and isinstance(v, unicode):
+ # skip this iteration if we have no keys or values to update
+ continue
+ if not isinstance(k, unicode):
+ k = unicode(k, 'utf-8')
@joeshaw
joeshaw Jun 11, 2012 Contributor

just as an FYI, this will still have the duplicate key issue. you'll need to delete the old key first.

+ if not isinstance(v, unicode):
+ v = unicode(v, 'utf-8')
+ d[k] = v
return d

0 comments on commit 098e9e3

Please sign in to comment.