code: def decode_msg(msg, enc='utf-8'):
      
      # We avoid the get_payload decoding machinery for raw
      # content-transfer-encodings potentially containing non-ascii characters,
      # such as 8bit or binary, as these are encoded using raw-unicode-escape which
      # seems to prevent subsequent utf-8 decoding.
      cte = str(msg.get('content-transfer-encoding', '')).lower()
      decode = cte not in ("8bit", "7bit", "binary")
      res = msg.get_payload(decode=decode)
      return decode_bytes(res, enc)
docs: Decodes a message fragment.
  
      Args: msg - A Message object representing the fragment
            enc - The encoding to use for decoding the message