summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-01-22 15:55:58 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2016-01-22 15:59:08 +0100
commit818ef90fdcfc6749786ba9ff38a1314910d92ca2 (patch)
treef8108da41e8a0ead3d196088f0cdd4dd6c73e760
parentba838832f03365587191b2e1849278d3eb414ee1 (diff)
downloadpsutil-818ef90fdcfc6749786ba9ff38a1314910d92ca2.tar.gz
#734: fix unicode issues on OSX
-rw-r--r--appveyor.yml6
-rw-r--r--psutil/_psutil_osx.c21
2 files changed, 24 insertions, 3 deletions
diff --git a/appveyor.yml b/appveyor.yml
index f80b17cf..25b9b600 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -10,6 +10,8 @@ environment:
# Pre-installed Python versions, which Appveyor may upgrade to
# a later point release.
+ # 32 bits
+
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"
@@ -26,6 +28,8 @@ environment:
PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "32"
+ # 64 bits
+
- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "64"
@@ -39,7 +43,7 @@ environment:
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python35-x64"
- PYTHON_VERSION: "3.4.x"
+ PYTHON_VERSION: "3.5.x"
PYTHON_ARCH: "64"
# Also build on a Python version not pre-installed by Appveyor.
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c
index 2378ae0e..76325930 100644
--- a/psutil/_psutil_osx.c
+++ b/psutil/_psutil_osx.c
@@ -160,6 +160,7 @@ psutil_proc_cwd(PyObject *self, PyObject *args) {
}
#if PY_MAJOR_VERSION >= 3
+ // TODO: have python pass ENCODING_ERRORS_HANDLER as an arg
return PyUnicode_DecodeFSDefault(pathinfo.pvi_cdir.vip_path);
#else
return Py_BuildValue("s", pathinfo.pvi_cdir.vip_path);
@@ -183,7 +184,12 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
psutil_raise_ad_or_nsp(pid);
return NULL;
}
+#if PY_MAJOR_VERSION >= 3
+ // TODO: have python pass ENCODING_ERRORS_HANDLER as an arg
+ return PyUnicode_DecodeFSDefault(buf);
+#else
return Py_BuildValue("s", buf);
+#endif
}
@@ -989,6 +995,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
PyObject *py_retlist = PyList_New(0);
PyObject *py_tuple = NULL;
+ PyObject *py_path = NULL;
if (py_retlist == NULL)
return NULL;
@@ -1053,15 +1060,24 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
// --- /errors checking
// --- construct python list
+#if PY_MAJOR_VERSION >= 3
+ // TODO: have python pass ENCODING_ERRORS_HANDLER as an arg
+ py_path = PyUnicode_DecodeFSDefault(vi.pvip.vip_path);
+#else
+ py_path = Py_BuildValue("s", vi.pvip.vip_path);
+#endif
+ if (! py_path)
+ goto error;
py_tuple = Py_BuildValue(
- "(si)",
- vi.pvip.vip_path,
+ "(Oi)",
+ py_path,
(int)fdp_pointer->proc_fd);
if (!py_tuple)
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
Py_DECREF(py_tuple);
+ Py_DECREF(py_path);
// --- /construct python list
}
}
@@ -1071,6 +1087,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
error:
Py_XDECREF(py_tuple);
+ Py_XDECREF(py_path);
Py_DECREF(py_retlist);
if (fds_pointer != NULL)
free(fds_pointer);