Correctly handle encoding numbers when POSTing.
authorCory Benfield <lukasaoz@gmail.com>
Mon, 6 Aug 2012 16:27:04 +0000 (17:27 +0100)
committerCory Benfield <lukasaoz@gmail.com>
Mon, 6 Aug 2012 16:40:27 +0000 (17:40 +0100)
requests/compat.py
requests/models.py

index af0207de0dbc1794429d757a76b60acdcb15baf4..201da3a96affe8a43d2a7ea4c14d42d09416dba9 100644 (file)
@@ -95,6 +95,7 @@ if is_py2:
     bytes = str
     str = unicode
     basestring = basestring
+    numeric_types = (int, long, float)
 
 
 
@@ -110,4 +111,5 @@ elif is_py3:
     str = str
     bytes = bytes
     basestring = (str,bytes)
+    numeric_types = (int, float)
 
index ef3728d10d2eb0270cb292d173e68dceb5fff63b..5908928a9dbdaf4783738086d83b4d33120c53c7 100644 (file)
@@ -32,7 +32,7 @@ from .utils import (
     DEFAULT_CA_BUNDLE_PATH)
 from .compat import (
     cookielib, urlparse, urlunparse, urljoin, urlsplit, urlencode, str, bytes,
-    StringIO, is_py2, chardet, json, builtin_str)
+    StringIO, is_py2, chardet, json, builtin_str, numeric_types)
 
 REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)
 CONTENT_CHUNK_SIZE = 10 * 1024
@@ -356,7 +356,7 @@ class Request(object):
             fields.update({k: (fn, fp.read())})
 
         for field in fields:
-            if isinstance(fields[field], float):
+            if isinstance(fields[field], numeric_types):
                 fields[field] = str(fields[field])
             if isinstance(fields[field], list):
                 newvalue = ', '.join(fields[field])