(filepath)
return retVal
Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
Patch for a Python Issue18171 ( http : // bugs . python . org / issue18171 )
def safeExpandUser(filepath):
    """
    Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
    """

    retVal = filepath

    try:
        retVal = os.path.expanduser(filepath)
    except UnicodeError:
        _ = locale.getdefaultlocale()
        encoding = _[1] if _ and len(_) > 1 else UNICODE_ENCODING
        retVal = getUnicode(os.path.expanduser(filepath.encode(encoding)), encoding=encoding)

    return retVal
def safeExpandUser ( filepath ) : retVal = filepath try : retVal = os . path . expanduser ( filepath ) except UnicodeError : _ = locale . getdefaultlocale ( ) encoding = _ [ 1 ] if _ and len ( _ ) > 1 else UNICODE_ENCODING retVal = getUnicode ( os . path . expanduser ( filepath . encode ( encoding ) ) , encoding = encoding ) return retVal