From 55bf436f8f6612f627cf0f562dd5d36e26e17c68 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Mon, 6 Aug 2012 17:27:04 +0100 Subject: [PATCH] Correctly handle encoding numbers when POSTing. --- requests/compat.py | 2 ++ requests/models.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requests/compat.py b/requests/compat.py index af0207d..201da3a 100644 --- a/requests/compat.py +++ b/requests/compat.py @@ -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) diff --git a/requests/models.py b/requests/models.py index ef3728d..5908928 100644 --- a/requests/models.py +++ b/requests/models.py @@ -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]) -- 2.7.4