in src/sagemaker_training/mapping.py [0:0]
def _decode(obj): # type: (bytes or str or unicode or object) -> unicode # noqa ignore=F821
"""Decode an object to unicode.
Args:
obj (bytes or str or unicode or anything serializable): Object to be decoded.
Returns:
Object decoded in unicode.
"""
if obj is None:
return ""
if six.PY3 and isinstance(obj, six.binary_type):
# transforms a byte string (b'') in unicode
return obj.decode("latin1")
elif six.PY3:
# PY3 strings are unicode.
return str(obj)
elif isinstance(obj, six.text_type):
# returns itself if it is unicode
return obj
else:
# decodes pY2 string to unicode
return str(obj).decode("utf-8")