summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-01-22 17:33:33 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2016-01-22 17:33:33 +0100
commit9481d97b6ad1e91670327cef649139fd4181ebc6 (patch)
treeeba9470459cf620165a5b468f0cf47c53adf3d9c
parent0255fb1bdb89eb3cc31dc4cc330ed7e406a1708c (diff)
downloadpsutil-9481d97b6ad1e91670327cef649139fd4181ebc6.tar.gz
#734: osx/name() correct unicode handling
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_psutil_osx.c6
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
+
}