summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-31 00:58:02 +0000
committerGerrit Code Review <review@openstack.org>2016-08-31 00:58:02 +0000
commit98085c961fc9421ffb07e62dacee67da9b7fcd16 (patch)
tree22244770ee6b32ac00eeef7d51f2e6278ea56f36 /swiftclient/client.py
parent39b9db35a0fb4db988725b68c129cb45cbb5f733 (diff)
parentab60e08e2e34ac4a87bc6c1701c6ace69bb392cf (diff)
downloadpython-swiftclient-98085c961fc9421ffb07e62dacee67da9b7fcd16.tar.gz
Merge "Convert numeric and boolean header values to strings"
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r--swiftclient/client.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index 988c7d9..a39185f 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -211,6 +211,13 @@ def quote(value, safe='/'):
def encode_utf8(value):
+ if type(value) in six.integer_types + (float, bool):
+ # As of requests 2.11.0, headers must be byte- or unicode-strings.
+ # Convert some known-good types as a convenience for developers.
+ # Note that we *don't* convert subclasses, as they may have overriddden
+ # __str__ or __repr__.
+ # See https://github.com/kennethreitz/requests/pull/3366 for more info
+ value = str(value)
if isinstance(value, six.text_type):
value = value.encode('utf8')
return value