code: def _decode_surrogatepass(data, codec):
      
  
      try:
          return data.decode(codec, _surrogatepass)
      except UnicodeDecodeError:
          if not _codec_can_decode_with_surrogatepass(codec):
              if _normalize_codec(codec) == "utf-16-be":
                  data = _swap_bytes(data)
                  codec = "utf-16-le"
              if _normalize_codec(codec) == "utf-16-le":
                  buffer_ = ctypes.create_string_buffer(data + b"\x00\x00")
                  value = ctypes.wstring_at(buffer_, len(data) // 2)
                  if value.encode("utf-16-le", _surrogatepass) != data:
                      raise
                  return value
              else:
                  raise
          else:
              raise
docs: Like data.decode(codec, 'surrogatepass') but makes utf-16-le/be work
      on Python < 3.4 + Windows
  
      https://bugs.python.org/issue27971
  
      Raises UnicodeDecodeError, LookupError