Skip to content

Commit

Permalink
#1040 fix unicode for connections() on netbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed May 1, 2017
1 parent 6bf50c9 commit b6c2636
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 1 addition & 5 deletions psutil/arch/bsd/netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,7 @@ psutil_get_cmdline(pid_t pid) {
// separator
if (argsize > 0) {
while (pos < argsize) {
#if PY_MAJOR_VERSION >= 3
py_arg = PyUnicode_DecodeFSDefault(&argstr[pos]);
#else
py_arg = Py_BuildValue("s", &argstr[pos]);
#endif
py_arg = psutil_PyUnicode_DecodeFSDefault(&argstr[pos]);
if (!py_arg)
goto error;
if (PyList_Append(py_retlist, py_arg))
Expand Down
10 changes: 5 additions & 5 deletions psutil/arch/bsd/netbsd_socks.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,17 @@ psutil_net_connections(PyObject *self, PyObject *args) {
strcpy(laddr, sun_src->sun_path);
strcpy(raddr, sun_dst->sun_path);
status = PSUTIL_CONN_NONE;
// TODO: handle unicode
py_laddr = Py_BuildValue("s", laddr);
py_laddr = psutil_PyUnicode_DecodeFSDefault(laddr);
if (! py_laddr)
goto error;
// TODO: handle unicode
py_raddr = Py_BuildValue("s", raddr);
py_raddr = psutil_PyUnicode_DecodeFSDefault(raddr);
if (! py_raddr)
goto error;
}

// append tuple to list
py_tuple = Py_BuildValue(
"(iiiNNii)",
"(iiiOOii)",
k->kif->ki_fd,
kp->kpcb->ki_family,
kp->kpcb->ki_type,
Expand All @@ -430,6 +428,8 @@ psutil_net_connections(PyObject *self, PyObject *args) {
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
Py_DECREF(py_laddr);
Py_DECREF(py_raddr);
Py_DECREF(py_tuple);
}
}
Expand Down

0 comments on commit b6c2636

Please sign in to comment.