summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCat Lee Ball 🎷🐛 <cball@google.com>2019-03-19 15:26:15 -0700
committerCat Lee Ball 🎷🐛 <cball@google.com>2019-03-19 15:26:15 -0700
commit8b246ee66f560bfb3357c4c918ce94e5e4e3e39f (patch)
tree80c3dcfc832c7feec96b17ce815d0369443dcf54
parent12366b7b9fa8ef5f6b88af35098cdf148eee57fa (diff)
downloadboto-8b246ee66f560bfb3357c4c918ce94e5e4e3e39f.tar.gz
Updated get_utf8 and get_binary_str
-rw-r--r--boto/utils.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/boto/utils.py b/boto/utils.py
index 22f97110..bf35dda9 100644
--- a/boto/utils.py
+++ b/boto/utils.py
@@ -859,10 +859,19 @@ def notify(subject, body=None, html_body=None, to_string=None,
boto.log.exception('notify failed')
-def get_utf8_value(value):
- if not six.PY2 and isinstance(value, bytes):
+def get_binary_str(value):
+ if isinstance(value, six.binary_type):
return value
+ if isinstance(value, six.text_type):
+ return six.ensure_binary(value)
+ return six.ensure_binary(str(value))
+
+def get_utf8_value(value):
+ if six.PY3:
+ if isinstance(value, bytes):
+ value = value.decode('utf-8')
+ return value
if not isinstance(value, six.string_types):
value = six.text_type(value)
@@ -1096,3 +1105,4 @@ def parse_host(hostname):
return hostname.split(']:', 1)[0].strip('[]')
else:
return hostname.split(':', 1)[0]
+