summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Manuskin <amanusk@protonmail.com>2019-04-25 06:17:11 +0300
committerGiampaolo Rodola <g.rodola@gmail.com>2019-04-25 11:17:11 +0800
commit7ee88afd9f6730289cf9e34f70210fdb387b8a71 (patch)
tree86a14ec27de8f09b2f222e5a1898d37fe8dccdbf
parent611b44ec6e830d98c768038c66683c3fa1a7b491 (diff)
downloadpsutil-7ee88afd9f6730289cf9e34f70210fdb387b8a71.tar.gz
Update cpu_freq to return 0 for max/min if not available (#1487)
-rw-r--r--CREDITS4
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_pslinux.py2
-rwxr-xr-xpsutil/tests/test_linux.py8
4 files changed, 9 insertions, 7 deletions
diff --git a/CREDITS b/CREDITS
index 626a79a8..a2fca99b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -62,7 +62,7 @@ I: 517, 607, 610, 1131, 1123, 1130, 1154, 1164, 1174, 1177, 1210, 1214, 1408,
N: Alex Manuskin
W: https://github.com/amanusk
D: FreeBSD cpu_freq(), OSX temperatures, support for Linux temperatures.
-I: 1284, 1345, 1350, 1352, 1472, 1481.
+I: 1284, 1345, 1350, 1352, 1472, 1481, 1487.
N: Jeff Tang
W: https://github.com/mrjefftang
@@ -611,4 +611,4 @@ I: 1480
N: Ammar Askar
E: ammar@ammaraskar.com
W: http://ammaraskar.com/
-I: 604, 1484 \ No newline at end of file
+I: 604, 1484
diff --git a/HISTORY.rst b/HISTORY.rst
index f2a0bd13..9a9df63c 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -20,6 +20,8 @@
**Bug fixes**
- 1223_: [Windows] boot_time() may return value on Windows XP.
+- 1456_: [Linux] cpu_freq() returns None instead of 0.0 when min/max not
+ available (patch by Alex Manuskin)
- 1462_: [Linux] (tests) make tests invariant to LANG setting (patch by
- 1463_: cpu_distribution.py script was broken.
Benjamin Drung)
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index eccfeed2..4c973c2d 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -712,7 +712,7 @@ elif os.path.exists("/proc/cpuinfo"):
for line in f:
if line.lower().startswith(b'cpu mhz'):
key, value = line.split(b'\t:', 1)
- ret.append(_common.scpufreq(float(value), None, None))
+ ret.append(_common.scpufreq(float(value), 0.0, 0.0))
return ret
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index e8745a75..4cdc9cbf 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -739,11 +739,11 @@ class TestSystemCPUFrequency(unittest.TestCase):
ret = psutil.cpu_freq()
assert ret
assert flags
- self.assertIsNone(ret.min)
- self.assertIsNone(ret.max)
+ self.assertEqual(ret.max, 0.0)
+ self.assertEqual(ret.min, 0.0)
for freq in psutil.cpu_freq(percpu=True):
- self.assertIsNone(freq.min)
- self.assertIsNone(freq.max)
+ self.assertEqual(ret.max, 0.0)
+ self.assertEqual(ret.min, 0.0)
finally:
reload_module(psutil._pslinux)
reload_module(psutil)