code: def _fsn2native(path):
      
  
      if not isinstance(path, fsnative_type):
          raise TypeError("path needs to be %s, not %s" % (
              fsnative_type.__name__, type(path).__name__))
  
      if is_unix:
          if PY3:
              try:
                  path = path.encode(_encoding, "surrogateescape")
              except UnicodeEncodeError:
                  # This look more like ValueError, but raising only one error
                  # makes things simpler... also one could say str + surrogates
                  # is its own type
                  raise TypeError(
                      "path contained Unicode code points not valid in"
                      "the current path encoding. To create a valid "
                      "path from Unicode use text2fsn()")
  
          if b"\x00" in path:
              raise TypeError("fsnative can't contain nulls")
      else:
          if u"\x00" in path:
              raise TypeError("fsnative can't contain nulls")
  
      return path
docs: Args:
          path (fsnative)
      Returns:
          `text` on Windows, `bytes` on Unix
      Raises:
          TypeError: in case the type is wrong or the ´str` on Py3 + Unix
              can't be converted to `bytes`
  
      This helper allows to validate the type and content of a path.
      To reduce overhead the encoded value for Py3 + Unix is returned so
      it can be reused.