code: def path_to_str(path):
      
      try:
          from pathlib import Path as _Path
      except ImportError:  # Python < 3.4
          class _Path:
              pass
      if isinstance(path, _Path):
          return str(path)
      return path
docs: Convert pathlib.Path objects to str; return other objects as-is.