Make sure we don't blow up on utf-8 str on py2

This commit is contained in:
Honza Kral
2013-07-14 15:51:04 +02:00
parent ab7d12e5de
commit 5aa6c86895
+6 -1
View File
@@ -19,7 +19,12 @@ def _escape(part):
part = ','.join(part)
if isinstance(part, (type(''), type(u''))):
# mark ',' as safe for nicer url in logs
return quote_plus(part.encode('utf-8'), ',')
try:
part = part.encode('utf-8')
except UnicodeDecodeError:
# Python 2 and str, no need to re-encode
pass
return quote_plus(part, ',')
return str(part)
def _escape_param(value):