diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-01 07:51:47 +0200 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-01 07:51:47 +0200 |
| commit | d93a437325d9028f717dfbc1344015b86311d24f (patch) | |
| tree | 75bad9c282bdd716715b299e934a744bb5cd5bdd /psutil | |
| parent | 9c22b44dc27607e508036c1cb846b9008c7eb39e (diff) | |
| download | psutil-d93a437325d9028f717dfbc1344015b86311d24f.tar.gz | |
#1040 fix unicode for memory_maps() on osx
Diffstat (limited to 'psutil')
| -rw-r--r-- | psutil/_psutil_osx.c | 10 | ||||
| -rw-r--r-- | psutil/arch/osx/process_info.c | 8 |
2 files changed, 10 insertions, 8 deletions
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index db1f997a..dbc69032 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -337,6 +337,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { vm_size_t size = 0; PyObject *py_tuple = NULL; + PyObject *py_path = NULL; PyObject *py_list = PyList_New(0); if (py_list == NULL) @@ -431,11 +432,14 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { } } + py_path = psutil_PyUnicode_DecodeFSDefault(buf); + if (! py_path) + goto error; py_tuple = Py_BuildValue( - "sssIIIIIH", + "ssOIIIIIH", addr_str, // "start-end"address perms, // "rwx" permissions - buf, // path + py_path, // path info.pages_resident * pagesize, // rss info.pages_shared_now_private * pagesize, // private info.pages_swapped_out * pagesize, // swapped @@ -448,6 +452,7 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) { if (PyList_Append(py_list, py_tuple)) goto error; Py_DECREF(py_tuple); + Py_DECREF(py_path); } // increment address for the next map/file @@ -463,6 +468,7 @@ error: if (task != MACH_PORT_NULL) mach_port_deallocate(mach_task_self(), task); Py_XDECREF(py_tuple); + Py_XDECREF(py_path); Py_DECREF(py_list); return NULL; } diff --git a/psutil/arch/osx/process_info.c b/psutil/arch/osx/process_info.c index 1c97b69f..28b02246 100644 --- a/psutil/arch/osx/process_info.c +++ b/psutil/arch/osx/process_info.c @@ -177,12 +177,8 @@ psutil_get_cmdline(long pid) { goto error; while (arg_ptr < arg_end && nargs > 0) { if (*arg_ptr++ == '\0') { -#if PY_MAJOR_VERSION >= 3 - py_arg = PyUnicode_DecodeFSDefault(curr_arg); -#else - py_arg = Py_BuildValue("s", curr_arg); -#endif - if (!py_arg) + py_arg = psutil_PyUnicode_DecodeFSDefault(curr_arg); + if (! py_arg) goto error; if (PyList_Append(py_retlist, py_arg)) goto error; |
