parameters: (path)
return_statement: return display_path
docstring: Convert a bytes (or text) path to text (unicode in Python 2) for display
      and logging purposes.
  
      This function should never error out. Also, this function is mainly needed
      for Python 2 since in Python 3 str paths are already text.
docstring_summary: Convert a bytes (or text) path to text (unicode in Python 2) for display
      and logging purposes.
docstring_tokens: Convert a bytes ( or text ) path to text ( unicode in Python 2 ) for display and logging purposes .
function: def path_to_display(path):
      # type: (Optional[str]) -> Optional[str]
      """
      Convert a bytes (or text) path to text (unicode in Python 2) for display
      and logging purposes.
  
      This function should never error out. Also, this function is mainly needed
      for Python 2 since in Python 3 str paths are already text.
      """
      if path is None:
          return None
      if isinstance(path, str):
          return path
      # Otherwise, path is a bytes object (str in Python 2).
      try:
          display_path = path.decode(sys.getfilesystemencoding(), 'strict')
      except UnicodeDecodeError:
          # Include the full bytes to make troubleshooting easier, even though
          # it may not be very human readable.
          display_path = ascii(path)
  
      return display_path
function_tokens: def path_to_display ( path ) : # type: (Optional[str]) -> Optional[str] if path is None : return None if isinstance ( path , str ) : return path # Otherwise, path is a bytes object (str in Python 2). try : display_path = path . decode ( sys . getfilesystemencoding ( ) , 'strict' ) except UnicodeDecodeError : # Include the full bytes to make troubleshooting easier, even though # it may not be very human readable. display_path = ascii ( path ) return display_path