code: def _stringify_path(filepath_or_buffer):
      
      try:
          import pathlib
          _PATHLIB_INSTALLED = True
      except ImportError:
          _PATHLIB_INSTALLED = False
  
      try:
          from py.path import local as LocalPath
          _PY_PATH_INSTALLED = True
      except ImportError:
          _PY_PATH_INSTALLED = False
  
      if hasattr(filepath_or_buffer, '__fspath__'):
          return filepath_or_buffer.__fspath__()
      if _PATHLIB_INSTALLED and isinstance(filepath_or_buffer, pathlib.Path):
          return str(filepath_or_buffer)
      if _PY_PATH_INSTALLED and isinstance(filepath_or_buffer, LocalPath):
          return filepath_or_buffer.strpath
      return _expand_user(filepath_or_buffer)
docs: Attempt to convert a path-like object to a string.
  
      Parameters
      ----------
      filepath_or_buffer : object to be converted
  
      Returns
      -------
      str_filepath_or_buffer : maybe a string version of the object
  
      Notes
      -----
      Objects supporting the fspath protocol (python 3.6+) are coerced
      according to its __fspath__ method.
  
      For backwards compatibility with older pythons, pathlib.Path and
      py.path objects are specially coerced.
  
      Any other object is passed through unchanged, which includes bytes,
      strings, buffers, or anything else that's not even path-like.