From 8d7bd9659acca85c66cbdd0c619a40f31d790fad Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Thu, 19 Dec 2024 12:34:29 +0100 Subject: [PATCH] rm py2 C handling of disk_usage() on windows --- psutil/arch/windows/disk.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/psutil/arch/windows/disk.c b/psutil/arch/windows/disk.c index 004174561..552929f38 100644 --- a/psutil/arch/windows/disk.c +++ b/psutil/arch/windows/disk.c @@ -44,33 +44,6 @@ PyObject * psutil_disk_usage(PyObject *self, PyObject *args) { BOOL retval; ULARGE_INTEGER _, total, free; - -#if PY_MAJOR_VERSION <= 2 - char *path; - - if (PyArg_ParseTuple(args, "u", &path)) { - Py_BEGIN_ALLOW_THREADS - retval = GetDiskFreeSpaceExW((LPCWSTR)path, &_, &total, &free); - Py_END_ALLOW_THREADS - goto return_; - } - - // on Python 2 we also want to accept plain strings other - // than Unicode - PyErr_Clear(); // drop the argument parsing error - if (PyArg_ParseTuple(args, "s", &path)) { - Py_BEGIN_ALLOW_THREADS - retval = GetDiskFreeSpaceEx(path, &_, &total, &free); - Py_END_ALLOW_THREADS - goto return_; - } - - return NULL; - -return_: - if (retval == 0) - return PyErr_SetFromWindowsErrWithFilename(0, path); -#else PyObject *py_path; wchar_t *path; @@ -91,7 +64,7 @@ psutil_disk_usage(PyObject *self, PyObject *args) { if (retval == 0) return PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, py_path); -#endif + return Py_BuildValue("(LL)", total.QuadPart, free.QuadPart); }