Skip to content

Commit

Permalink
Merge branch 'master' into 655-windows-unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Aug 26, 2015
2 parents 4d98b05 + 0847640 commit e907b34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 10 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ Bug tracker at https://github.com/giampaolo/psutil/issues

- #648: CI test integration for OSX. (patch by Jeff Tang)
- #663: net_if_addrs() now returns point-to-point addresses (for VPNs).
- #655: [Windows] str/uniocde unification. Different methods returning a string
now return unicode on both Python 2 and 3:
- net_if_stats
- net_io_counters
- users
- Process.username
- Process.name
- Process.cmdline

**Bug fixes**

- #513: [Linux] fixed integer overflow for RLIM_INFINITY.
- #641: [Windows] fixed many compilation warnings. (patch by Jeff Tang)
- #655: [Windows] net_if_stats unicode error in in case of non-ASCII NIC names.
- #655: [Windows] net_if_stats UnicodeDecodeError in case of non-ASCII NIC
names.
- #659: [Linux] compilation error on Suse 10.
- #664: [Linux] compilation error on Alpine Linux. (patch by Bart van Kleef)
- #670: [Windows] segfgault of net_if_addrs() in case of non-ASCII NIC names.
Expand Down
11 changes: 6 additions & 5 deletions psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ static PyObject *
psutil_proc_name(PyObject *self, PyObject *args) {
long pid;
int ok;
PROCESSENTRY32 pentry;
PROCESSENTRY32W pentry;
HANDLE hSnapShot;

if (! PyArg_ParseTuple(args, "l", &pid))
Expand All @@ -648,8 +648,8 @@ psutil_proc_name(PyObject *self, PyObject *args) {
PyErr_SetFromWindowsErr(0);
return NULL;
}
pentry.dwSize = sizeof(PROCESSENTRY32);
ok = Process32First(hSnapShot, &pentry);
pentry.dwSize = sizeof(PROCESSENTRY32W);
ok = Process32FirstW(hSnapShot, &pentry);
if (! ok) {
CloseHandle(hSnapShot);
PyErr_SetFromWindowsErr(0);
Expand All @@ -658,9 +658,10 @@ psutil_proc_name(PyObject *self, PyObject *args) {
while (ok) {
if (pentry.th32ProcessID == pid) {
CloseHandle(hSnapShot);
return Py_BuildValue("s", pentry.szExeFile);
return PyUnicode_FromWideChar(
pentry.szExeFile, wcslen(pentry.szExeFile));
}
ok = Process32Next(hSnapShot, &pentry);
ok = Process32NextW(hSnapShot, &pentry);
}

CloseHandle(hSnapShot);
Expand Down

0 comments on commit e907b34

Please sign in to comment.