code: def bytes2fsn(data, encoding="utf-8"):
      
  
      if not isinstance(data, bytes):
          raise TypeError("data needs to be bytes")
  
      if is_win:
          if encoding is None:
              raise ValueError("invalid encoding %r" % encoding)
          try:
              path = _decode_surrogatepass(data, encoding)
          except LookupError:
              raise ValueError("invalid encoding %r" % encoding)
          if u"\x00" in path:
              raise ValueError("contains nulls")
          return path
      else:
          if b"\x00" in data:
              raise ValueError("contains nulls")
          if PY2:
              return data
          else:
              return data.decode(_encoding, "surrogateescape")
docs: Args:
          data (bytes): The data to convert
          encoding (`str`): encoding used for Windows
      Returns:
          `fsnative`
      Raises:
          TypeError: If no `bytes` path is passed
          ValueError: If decoding fails or the encoding is invalid
  
      Turns `bytes` to a `fsnative` path.
  
      The passed *encoding* is only used on platforms where paths are not
      associated with an encoding (Windows for example).
  
      For Windows paths ``WTF-8`` is accepted if ``utf-8`` is used and
      ``WTF-16`` accepted if ``utf-16-le`` is used.