Skip to content

Commit

Permalink
Merge branch '1040-fix-unicode' of github.com:giampaolo/psutil into 1…
Browse files Browse the repository at this point in the history
…040-fix-unicode
  • Loading branch information
giampaolo committed May 2, 2017
2 parents 97eaf71 + 85744f6 commit 8c8b510
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions psutil/_psutil_sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,25 +123,31 @@ psutil_proc_name_and_args(PyObject *self, PyObject *args) {
const char *procfs_path;
PyObject *py_name;
PyObject *py_args;
PyObject *py_retlist;

if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
sprintf(path, "%s/%i/psinfo", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;

// TODO: probably have to Py_INCREF here.
py_name = PyUnicode_DecodeFSDefault(info.pr_fname);
if (!py_name)
goto error;
py_args = PyUnicode_DecodeFSDefault(info.pr_psargs);
if (!py_args)
goto error;
return Py_BuildValue("OO", py_name, py_args);
py_retlist = Py_BuildValue("OO", py_name, py_args);
if (!py_retlist)
goto error;
Py_DECREF(py_name);
Py_DECREF(py_args);
return py_retlist;

error:
Py_XDECREF(py_name);
Py_XDECREF(py_args);
Py_XDECREF(py_retlist);
return NULL;
}

Expand Down

0 comments on commit 8c8b510

Please sign in to comment.