[PATCH for-11.0 08/15] tests/functional/x86_64/test_memlock: Silence pylint warnings

Thomas Huth posted 15 patches 1 day, 4 hours ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Radoslaw Biernacki <rad@semihalf.com>, Peter Maydell <peter.maydell@linaro.org>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, Eric Auger <eric.auger@redhat.com>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, "Cédric Le Goater" <clg@kaod.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, BALATON Zoltan <balaton@eik.bme.hu>, Glenn Miles <milesg@linux.ibm.com>, Nicholas Piggin <npiggin@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Zhao Liu <zhao1.liu@intel.com>
[PATCH for-11.0 08/15] tests/functional/x86_64/test_memlock: Silence pylint warnings
Posted by Thomas Huth 1 day, 4 hours ago
From: Thomas Huth <thuth@redhat.com>

Pylint complains about a missing "encoding" parameter for the open()
function here, and about a missing return statement in the "except"
block (which cannot happen since skipTest() never returns). Rework
the code a little bit to silence the warnings.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/functional/x86_64/test_memlock.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/functional/x86_64/test_memlock.py b/tests/functional/x86_64/test_memlock.py
index 81bce80b0c4..f970a2c3095 100755
--- a/tests/functional/x86_64/test_memlock.py
+++ b/tests/functional/x86_64/test_memlock.py
@@ -69,11 +69,13 @@ def get_process_status_values(self, pid: int) -> Dict[str, int]:
         return result
 
     def _get_raw_process_status(self, pid: int) -> str:
+        status = None
         try:
-            with open(f'/proc/{pid}/status', 'r') as f:
-                return f.read()
+            with open(f'/proc/{pid}/status', 'r', encoding="ascii") as f:
+                status = f.read()
         except FileNotFoundError:
             self.skipTest("Can't open status file of the process")
+        return status
 
 
 if __name__ == '__main__':
-- 
2.51.1
Re: [PATCH for-11.0 08/15] tests/functional/x86_64/test_memlock: Silence pylint warnings
Posted by Philippe Mathieu-Daudé an hour ago
On 19/11/25 09:26, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> Pylint complains about a missing "encoding" parameter for the open()
> function here, and about a missing return statement in the "except"
> block (which cannot happen since skipTest() never returns). Rework
> the code a little bit to silence the warnings.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/functional/x86_64/test_memlock.py | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>