summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-03 05:20:21 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-03 05:20:21 +0200
commita655055d198dd2f3cfb160a23173f1767b36d7aa (patch)
treee198284365fb53116e2ec5e261bb91478e1ea379
parent2d1028c7d4770a83937e9b80e9d25ef2774961b2 (diff)
downloadpsutil-a655055d198dd2f3cfb160a23173f1767b36d7aa.tar.gz
#1040: use default fs encoding instead of utf8 when decoding from ubytes to unicode
-rw-r--r--psutil/_pswindows.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index 3d54b86c..266c1220 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -184,7 +184,9 @@ def convert_dos_path(s):
"C:\Windows\systemew\file.txt"
"""
if PY3 and not isinstance(s, str):
- s = s.decode('utf8')
+ # TODO: probably getting here means there's something wrong;
+ # probably needs to be removed.
+ s = s.decode(FS_ENCODING, errors=PY2_ENCODING_ERRS)
rawdrive = '\\'.join(s.split('\\')[:3])
driveletter = cext.win32_QueryDosDevice(rawdrive)
return os.path.join(driveletter, s[len(rawdrive):])
@@ -761,9 +763,9 @@ class Process(object):
else:
for addr, perm, path, rss in raw:
assert isinstance(path, unicode), path
+ path = convert_dos_path(path)
if not PY3:
path = py2_strencode(path)
- path = convert_dos_path(path)
addr = hex(addr)
yield (addr, perm, path, rss)