summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-03-17 10:54:57 -0700
committerGiampaolo Rodola <g.rodola@gmail.com>2019-03-17 10:54:57 -0700
commit2e0016faa875d83665bb596e0b2d851d12337fb3 (patch)
tree86963b3593f5f7580b959db1f81e2cfb75974654
parent7b70d288648aa1117c2f7043092269de35105bec (diff)
downloadpsutil-2e0016faa875d83665bb596e0b2d851d12337fb3.tar.gz
update HISTORY / CREDITS, fix some C warnings
-rw-r--r--CREDITS3
-rw-r--r--HISTORY.rst1
-rw-r--r--psutil/_psutil_windows.c9
-rwxr-xr-xpsutil/tests/test_windows.py3
4 files changed, 6 insertions, 10 deletions
diff --git a/CREDITS b/CREDITS
index 38cd6939..ee2682eb 100644
--- a/CREDITS
+++ b/CREDITS
@@ -592,3 +592,6 @@ N: Benjamin Drung
D: make tests invariant to LANG setting
W: https://github.com/bdrung
I: 1462
+
+N: Xiaoling Bao
+I: 1223
diff --git a/HISTORY.rst b/HISTORY.rst
index a5a155d3..f48229d4 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -16,6 +16,7 @@
- 1462_: [Linux] (tests) make tests invariant to LANG setting (patch by
Benjamin Drung)
- 1463_: cpu_distribution.py script was broken.
+- 1223_: [Windows] boot_time() may return value on Windows XP.
5.6.1
=====
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index a11d8c5c..9fd8d9c7 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -138,8 +138,6 @@ psutil_boot_time(PyObject *self, PyObject *args) {
time_t pt;
FILETIME fileTime;
ULONGLONG ll;
- HINSTANCE hKernel32;
- psutil_GetTickCount64 = NULL;
GetSystemTimeAsFileTime(&fileTime);
/*
@@ -151,7 +149,7 @@ psutil_boot_time(PyObject *self, PyObject *args) {
The time_t is a 32-bit value for the number of seconds since
January 1, 1970. A FILETIME is a 64-bit for the number of
100-nanosecond periods since January 1, 1601. Convert by
- subtracting the number of 100-nanosecond period betwee 01-01-1970
+ subtracting the number of 100-nanosecond period between 01-01-1970
and 01-01-1601, from time_t the divide by 1e+7 to get to the same
base granularity.
*/
@@ -159,11 +157,6 @@ psutil_boot_time(PyObject *self, PyObject *args) {
(fileTime.dwHighDateTime)) << 32) + fileTime.dwLowDateTime;
pt = (time_t)((ll - 116444736000000000ull) / 10000000ull);
- // GetTickCount64() is Windows Vista+ only. Dynamically load
- // GetTickCount64() at runtime. We may have used
- // "#if (_WIN32_WINNT >= 0x0600)" pre-processor but that way
- // the produced exe/wheels cannot be used on Windows XP, see:
- // https://github.com/giampaolo/psutil/issues/811#issuecomment-230639178
if (psutil_GetTickCount64 != NULL) {
// Windows >= Vista
uptime = psutil_GetTickCount64() / 1000ull;
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index e0bfdbb8..a3a6b61d 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -214,8 +214,7 @@ class TestSystemAPIs(unittest.TestCase):
wmi_btime_str, "%Y%m%d%H%M%S")
psutil_dt = datetime.datetime.fromtimestamp(psutil.boot_time())
diff = abs((wmi_btime_dt - psutil_dt).total_seconds())
- # Wmic time is 2-3 secs lower for some reason; that's OK.
- self.assertLessEqual(diff, 3)
+ self.assertLessEqual(diff, 1)
def test_boot_time_fluctuation(self):
# https://github.com/giampaolo/psutil/issues/1007