diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-01-22 17:33:33 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-01-22 17:33:33 +0100 |
commit | 9481d97b6ad1e91670327cef649139fd4181ebc6 (patch) | |
tree | eba9470459cf620165a5b468f0cf47c53adf3d9c | |
parent | 0255fb1bdb89eb3cc31dc4cc330ed7e406a1708c (diff) | |
download | psutil-9481d97b6ad1e91670327cef649139fd4181ebc6.tar.gz |
#734: osx/name() correct unicode handling
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rw-r--r-- | psutil/_psutil_osx.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 206238f4..5e4af830 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -14,7 +14,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues - #734: [Linux] non unicode data not correctly handled in Python 3 for process name() and exe(). - #734: [OSX] non unicode data not correctly handled in Python 3 for process - cwd(), exe(), open_files(). + name(), cwd(), exe(), open_files(). 3.4.2 - 2016-01-20 diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 76325930..be007c55 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -138,7 +138,13 @@ psutil_proc_name(PyObject *self, PyObject *args) { return NULL; if (psutil_get_kinfo_proc(pid, &kp) == -1) return NULL; +#if PY_MAJOR_VERSION >= 3 + // TODO: have python pass ENCODING_ERRORS_HANDLER as an arg + return PyUnicode_DecodeFSDefault(kp.kp_proc.p_comm); +#else return Py_BuildValue("s", kp.kp_proc.p_comm); +#endif + } |