Permalink
Browse files

Deal with unicode encoding problem.

  • Loading branch information...
1 parent 945b8c2 commit 1532cfef5935b047da75217837da5cd7c04fa1ba Roland Hedberg committed Jun 14, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/oic/oauth2/message.py
@@ -122,7 +122,11 @@ def to_urlencoded(self, lev=0):
except Exception, err:
params.append((key, str(val)))
- return urllib.urlencode(params)
+ try:
+ return urllib.urlencode(params)
+ except UnicodeEncodeError:
+ _val = [(k,unicode.encode(v, "utf-8")) for k,v in params]
+ return urllib.urlencode(_val)
def serialize(self, method="urlencoded", lev=0, **kwargs):
return getattr(self, "to_%s" % method)(lev=lev, **kwargs)

0 comments on commit 1532cfe

Please sign in to comment.