Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 337eb98

Browse files
committed
Fixes #1347
1 parent 690347a commit 337eb98

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/core/common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,9 +1583,10 @@ def safeExpandUser(filepath):
15831583

15841584
try:
15851585
retVal = os.path.expanduser(filepath)
1586-
except UnicodeDecodeError:
1586+
except UnicodeError:
15871587
_ = locale.getdefaultlocale()
1588-
retVal = getUnicode(os.path.expanduser(filepath.encode(_[1] if _ and len(_) > 1 else UNICODE_ENCODING)))
1588+
encoding = _[1] if _ and len(_) > 1 else UNICODE_ENCODING
1589+
retVal = getUnicode(os.path.expanduser(filepath.encode(encoding)), encoding=encoding)
15891590

15901591
return retVal
15911592

@@ -2115,7 +2116,7 @@ def getUnicode(value, encoding=None, noneToNull=False):
21152116
elif isinstance(value, basestring):
21162117
while True:
21172118
try:
2118-
return unicode(value, encoding or kb.get("pageEncoding") or UNICODE_ENCODING)
2119+
return unicode(value, encoding or (kb.get("pageEncoding") if kb.get("originalPage") else None) or UNICODE_ENCODING)
21192120
except UnicodeDecodeError, ex:
21202121
try:
21212122
return unicode(value, UNICODE_ENCODING)

0 commit comments

Comments
 (0)