From 8b246ee66f560bfb3357c4c918ce94e5e4e3e39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cat=20Lee=20Ball=20=F0=9F=8E=B7=F0=9F=90=9B?= Date: Tue, 19 Mar 2019 15:26:15 -0700 Subject: Updated get_utf8 and get_binary_str --- boto/utils.py | 14 ++++++++++++-- 1 file 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] + -- cgit v1.2.1