8000 Allow both unicode strings and encoded byte strings in request data · jseims/twilio-python@6027292 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6027292

Browse files
committed
Allow both unicode strings and encoded byte strings in request data
1 parent 6e2b93f commit 6027292

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

twilio/rest/resources.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ def make_request(method, url,
128128
if data is not None:
129129
udata = {}
130130
for k, v in data.iteritems():
131-
udata[k.encode('utf-8')] = v.encode('utf-8')
131+
try:
132+
udata[k.encode('utf-8')] = unicode(v).encode('utf-8')
133+
except UnicodeDecodeError:
134+
udata[k.encode('utf-8')] = unicode(v, 'utf-8').encode('utf-8')
132135
data = urlencode(udata)
133136

134137
if params is not None:

0 commit comments

Comments
 (0)
0