From b616ce046bbeb664d7806f2d7303ff741efa493c Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 16 Feb 2018 10:22:23 -0600 Subject: [PATCH] Add clarifying comments --- salt/utils/data.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/salt/utils/data.py b/salt/utils/data.py index 6c7d65b142..2dcca51be8 100644 --- a/salt/utils/data.py +++ b/salt/utils/data.py @@ -111,6 +111,9 @@ def decode(data, encoding=None, errors='strict', keep=False, data = salt.utils.stringutils.to_unicode( data, encoding, errors, normalize) except TypeError: + # to_unicode raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply means we + # are going to leave the value as-is. pass except UnicodeDecodeError: if not keep: @@ -138,6 +141,9 @@ def decode_dict(data, encoding=None, errors='strict', keep=False, key = salt.utils.stringutils.to_unicode( key, encoding, errors, normalize) except TypeError: + # to_unicode raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeDecodeError: if not keep: @@ -160,6 +166,9 @@ def decode_dict(data, encoding=None, errors='strict', keep=False, value = salt.utils.stringutils.to_unicode( value, encoding, errors, normalize) except TypeError: + # to_unicode raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeDecodeError: if not keep: @@ -194,6 +203,9 @@ def decode_list(data, encoding=None, errors='strict', keep=False, item = salt.utils.stringutils.to_unicode( item, encoding, errors, normalize) except TypeError: + # to_unicode raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeDecodeError: if not keep: @@ -240,6 +252,9 @@ def encode(data, encoding=None, errors='strict', keep=False, try: return salt.utils.stringutils.to_bytes(data, encoding, errors) except TypeError: + # to_bytes raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeEncodeError: if not keep: @@ -265,6 +280,9 @@ def encode_dict(data, encoding=None, errors='strict', keep=False, try: key = salt.utils.stringutils.to_bytes(key, encoding, errors) except TypeError: + # to_bytes raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeEncodeError: if not keep: @@ -285,6 +303,9 @@ def encode_dict(data, encoding=None, errors='strict', keep=False, try: value = salt.utils.stringutils.to_bytes(value, encoding, errors) except TypeError: + # to_bytes raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeEncodeError: if not keep: @@ -318,6 +339,9 @@ def encode_list(data, encoding=None, errors='strict', keep=False, try: item = salt.utils.stringutils.to_bytes(item, encoding, errors) except TypeError: + # to_bytes raises a TypeError when input is not a + # string/bytestring/bytearray. This is expected and simply + # means we are going to leave the value as-is. pass except UnicodeEncodeError: if not keep: