diff --git a/HISTORY.rst b/HISTORY.rst index 44afa960f..095c90623 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,5 +1,15 @@ *Bug tracker at https://github.com/giampaolo/psutil/issues* +5.5.1 +===== + +XXXX-XX-XX + +**Bug fixes** + +- 1394_: [Windows] Process.exe() returns "[Error 0] The operation completed + successfully" when Python process runs in "Virtual Secure Mode". + 5.5.0 ===== diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c index bd27b5f9c..5b7a56ad9 100644 --- a/psutil/_psutil_linux.c +++ b/psutil/_psutil_linux.c @@ -211,6 +211,7 @@ psutil_disk_partitions(PyObject *self, PyObject *args) { file = setmntent(mtab_path, "r"); Py_END_ALLOW_THREADS if ((file == 0) || (file == NULL)) { + psutil_debug("setmntent() failed"); PyErr_SetFromErrnoWithFilename(PyExc_OSError, mtab_path); goto error; } @@ -298,8 +299,10 @@ psutil_proc_cpu_affinity_get(PyObject *self, PyObject *args) { while (1) { setsize = CPU_ALLOC_SIZE(ncpus); mask = CPU_ALLOC(ncpus); - if (mask == NULL) + if (mask == NULL) { + psutil_debug("CPU_ALLOC() failed"); return PyErr_NoMemory(); + } if (sched_getaffinity(pid, setsize, mask) == 0) break; CPU_FREE(mask); diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index ce44258a3..4251e0c71 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -765,7 +765,11 @@ psutil_proc_exe(PyObject *self, PyObject *args) { if (NULL == hProcess) return NULL; if (GetProcessImageFileNameW(hProcess, exe, MAX_PATH) == 0) { - PyErr_SetFromWindowsErr(0); + // https://github.com/giampaolo/psutil/issues/1394 + if (GetLastError() == 0) + PyErr_SetFromWindowsErr(ERROR_ACCESS_DENIED); + else + PyErr_SetFromWindowsErr(0); CloseHandle(hProcess); return NULL; } diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py index bb5882422..664d5b6b1 100644 --- a/psutil/_pswindows.py +++ b/psutil/_pswindows.py @@ -698,7 +698,9 @@ def exe(self): # see https://github.com/giampaolo/psutil/issues/528 if self.pid in (0, 4): raise AccessDenied(self.pid, self._name) - return py2_strencode(convert_dos_path(cext.proc_exe(self.pid))) + exe = cext.proc_exe(self.pid) + exe = convert_dos_path(exe) + return py2_strencode(exe) @wrap_exceptions def cmdline(self):