From 8319458ebe96a33cca60865af97503e31c5bceab Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 10 Nov 2020 00:33:09 +0100 Subject: psutil did not compile on pypy2 on win --- psutil/_psutil_common.c | 17 +++++++++++++---- psutil/arch/windows/wmi.c | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index 4178e0c0..a01919d5 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -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; @@ -58,7 +57,17 @@ error: 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) // ==================================================================== diff --git a/psutil/arch/windows/wmi.c b/psutil/arch/windows/wmi.c index 0a1fb891..ec5cdeb5 100644 --- a/psutil/arch/windows/wmi.c +++ b/psutil/arch/windows/wmi.c @@ -10,6 +10,8 @@ #include #include +#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 -- cgit v1.2.1