]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/functional/x86_64/test_memlock: Silence pylint warnings
authorThomas Huth <thuth@redhat.com>
Wed, 19 Nov 2025 08:26:29 +0000 (09:26 +0100)
committerThomas Huth <thuth@redhat.com>
Fri, 21 Nov 2025 07:33:15 +0000 (08:33 +0100)
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.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251119082636.43286-9-thuth@redhat.com>

tests/functional/x86_64/test_memlock.py

index 81bce80b0c4ec0c467a4e53e953c25ddf42d0789..f970a2c30959437dc4f1f16288e3843886debd0d 100755 (executable)
@@ -69,11 +69,13 @@ class MemlockTest(QemuSystemTest):
         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__':