def decode_path(path):
 if isinstance(path, unicode):
  return path
 try:
  path = path.decode(sys.getfilesystemencoding(), 'strict')
 except AttributeError:
  return nodes.reprunicode(path)
 except UnicodeDecodeError:
  try:
   path = path.decode('utf-8', 'strict')
  except UnicodeDecodeError:
   path = path.decode('ascii', 'replace')
 return nodes.reprunicode(path)

def decode_path ( path ) : if isinstance ( path , unicode ) : return path try : path = path . decode ( sys . getfilesystemencoding ( ) , 'strict' ) except AttributeError : return nodes . reprunicode ( path ) except UnicodeDecodeError : try : path = path . decode ( 'utf-8' , 'strict' ) except UnicodeDecodeError : path = path . decode ( 'ascii' , 'replace' ) return nodes . reprunicode ( path )
ensure path is unicode .