From 2461cf656843a5ecd33ae5397d12a06d71885737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Thu, 4 Jun 2020 14:00:59 +0200 Subject: [PATCH] cpu: Fix string comparisons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'is' operator is used to determine object identity. What we want to do here instead is a value comparison, i.e. the "==" operator. With the 'is' operator, the conditions would likely never evaluate to true. This fixes errors such as these (they seem to get produced during byte compilation; you can trigger them just by running Tuned). /root/tuned/tuned/plugins/plugin_cpu.py:76: SyntaxWarning: "is" with a literal. Did you mean "=="? if vendor is "GenuineIntel": /root/tuned/tuned/plugins/plugin_cpu.py:78: SyntaxWarning: "is" with a literal. Did you mean "=="? elif vendor is "AuthenticAMD" or vendor is "HygonGenuine": /root/tuned/tuned/plugins/plugin_cpu.py:78: SyntaxWarning: "is" with a literal. Did you mean "=="? elif vendor is "AuthenticAMD" or vendor is "HygonGenuine": This fixes commit 29022a0edf651347f432463f359b0f3c42ee5348. Signed-off-by: Ondřej Lysoněk --- tuned/plugins/plugin_cpu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index b6f14b1..1c66282 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -73,9 +73,9 @@ class CPULatencyPlugin(base.Plugin): # "TransmetaCPU", "UMC UMC UMC" cpu = procfs.cpuinfo() vendor = cpu.tags.get("vendor_id") - if vendor is "GenuineIntel": + if vendor == "GenuineIntel": self._is_intel = True - elif vendor is "AuthenticAMD" or vendor is "HygonGenuine": + elif vendor == "AuthenticAMD" or vendor == "HygonGenuine": self._is_amd = True else: # We always assign Intel, unless we know better