Patch for an Issue #1124

This commit is contained in:
Miroslav Stampar
2015-01-21 09:26:30 +01:00
parent cd743ab098
commit 02b3eb941f
2 changed files with 22 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import hashlib
import httplib
import inspect
import json
import locale
import logging
import ntpath
import os
@@ -1558,6 +1559,22 @@ def normalizePath(filepath):
return retVal
def safeExpandUser(filepath):
"""
Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
"""
retVal = filepath
try:
retVal = os.path.expanduser(filepath)
except UnicodeDecodeError:
_ = locale.getdefaultlocale()
retVal = getUnicode(os.path.expanduser(filepath.encode(_[1] if _ and len(_) > 1 else UNICODE_ENCODING)))
print retVal
return retVal
def safeStringFormat(format_, params):
"""
Avoids problems with inappropriate string format strings