Added needed cast for when POSTing data and files (Issue #661)
authorVictoria Mo <vm2355@columbia.edu>
Sat, 14 Jul 2012 22:26:38 +0000 (18:26 -0400)
committerVictoria Mo <vm2355@columbia.edu>
Sat, 14 Jul 2012 22:28:34 +0000 (18:28 -0400)
Co-Authored By: Timnit Gebru <tgebru@gmail.com>
Co-Authored By: Sarah Gonzalez <smar.gonz@gmail.com>
Co-Authored By: Leila Muhtasib <muhtasib@gmail.com>

requests/models.py

index 727654c89c3852806a3e9020a7b19190451b739b..dc0aef8d7ef2cadf87c4ee62ae88d8890388000a 100644 (file)
@@ -355,6 +355,13 @@ class Request(object):
                 fp = StringIO(fp)
             fields.update({k: (fn, fp.read())})
 
+        for field in fields:
+            if isinstance(fields[field], float):
+                fields[field] = str(fields[field])
+            if isinstance(fields[field], list):
+                newvalue = ', '.join(fields[field])
+                fields[field] = newvalue
+                
         (body, content_type) = encode_multipart_formdata(fields)
 
         return (body, content_type)