summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Ball <43632885+catleeball@users.noreply.github.com>2019-03-27 17:23:46 -0700
committerGitHub <noreply@github.com>2019-03-27 17:23:46 -0700
commit2f202c95b8021d56466ebd62383664a1cf3992a0 (patch)
tree20f537a65b17a31af3c41f08e1c83185aba1bfbf
parent0165f94bcde65ee08289d81013c1e48437bb7825 (diff)
parent6b1b976b647ad5ee7e9214e305dc55264108244c (diff)
downloadboto-2f202c95b8021d56466ebd62383664a1cf3992a0.tar.gz
Merge pull request #5 from catleeball/utf8able
Use get_utf8able_str over get_utf8_value
-rw-r--r--boto/utils.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/boto/utils.py b/boto/utils.py
index 7dfe0591..ed39c253 100644
--- a/boto/utils.py
+++ b/boto/utils.py
@@ -1127,14 +1127,19 @@ def get_utf8able_str(s, errors='strict'):
raise TypeError('not expecting type "%s"' % type(s))
-def get_utf8_value(self, value):
- """This replaces public interface get_utf8_value with new implementation.
+def get_utf8_value(value):
+ if isinstance(value, bytes):
+ value.decode('utf-8')
+ return value
+
+ if not isinstance(value, six.string_types):
+ value = six.text_type(value)
+
+ if isinstance(value, six.text_type):
+ value = value.encode('utf-8')
+
+ return value
- The old implementation of get_utf8_value has been deprecated and replaced
- with get_utf8able_str.
- """
- return get_utf8able_str(value)
-
def print_to_fd(*objects, **kwargs):
"""A Python 2/3 compatible analogue to the print function.