Skip to content

Commit

Permalink
[Windows] add support for pypy2 on windows (#1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo authored Nov 9, 2020
1 parent 4791b40 commit 1e8fdf2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ XXXX-XX-XX

**Enhancements**

- 1875_: `disk_partitions()` exposes 2 extra fields: `maxfile` and `maxpath`,
- 1872_: [Windows] added support for PyPy 2.7.
- 1863_: `disk_partitions()` exposes 2 extra fields: `maxfile` and `maxpath`,
which are the maximum file name and path name length.

**Bug fixes**

- 1866_: [Windows] process exe(), cmdline(), environ() may raise "invalid
access to memory location" on Python 3.9.

5.7.3
=====

Expand Down
17 changes: 13 additions & 4 deletions psutil/_psutil_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ int PSUTIL_TESTING = 0;
// ====================================================================

// PyPy on Windows
#if defined(PSUTIL_WINDOWS) && \
defined(PYPY_VERSION) && \
!defined(PyErr_SetFromWindowsErrWithFilename)
#if defined(PSUTIL_WINDOWS) && defined(PYPY_VERSION)
#if !defined(PyErr_SetFromWindowsErrWithFilename)
PyObject *
PyErr_SetFromWindowsErrWithFilename(int winerr, const char *filename) {
PyObject *py_exc = NULL;
Expand Down Expand Up @@ -58,7 +57,17 @@ PyErr_SetFromWindowsErrWithFilename(int winerr, const char *filename) {
Py_XDECREF(py_winerr);
return NULL;
}
#endif // PYPY on Windows
#endif // !defined(PyErr_SetFromWindowsErrWithFilename)


// PyPy 2.7
#if !defined(PyErr_SetFromWindowsErr)
PyObject *
PyErr_SetFromWindowsErr(int winerr) {
return PyErr_SetFromWindowsErrWithFilename(winerr, "");
}
#endif // !defined(PyErr_SetFromWindowsErr)
#endif // defined(PSUTIL_WINDOWS) && defined(PYPY_VERSION)


// ====================================================================
Expand Down
2 changes: 2 additions & 0 deletions psutil/arch/windows/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <windows.h>
#include <pdh.h>

#include "../../_psutil_common.h"


// We use an exponentially weighted moving average, just like Unix systems do
// https://en.wikipedia.org/wiki/Load_(computing)#Unix-style_load_calculation
Expand Down

0 comments on commit 1e8fdf2

Please sign in to comment.