def _stringify_path(filepath_or_buffer):
try:<EOL><INDENT>import pathlib<EOL>_PATHLIB_INSTALLED = True<EOL><DEDENT>except ImportError:<EOL><INDENT>_PATHLIB_INSTALLED = False<EOL><DEDENT>try:<EOL><INDENT>from py.path import local as LocalPath<EOL>_PY_PATH_INSTALLED = True<EOL><DEDENT>except ImportError:<EOL><INDENT>_PY_PATH_INSTALLED = False<EOL><DEDENT>if hasattr(filepath_or_buffer, '<STR_LIT>'):<EOL><INDENT>return filepath_or_buffer.__fspath__()<EOL><DEDENT>if _PATHLIB_INSTALLED and isinstance(filepath_or_buffer, pathlib.Path):<EOL><INDENT>return str(filepath_or_buffer)<EOL><DEDENT>if _PY_PATH_INSTALLED and isinstance(filepath_or_buffer, LocalPath):<EOL><INDENT>return filepath_or_buffer.strpath<EOL><DEDENT>return _expand_user(filepath_or_buffer)<EOL>
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.