From: Thomas Huth <[email protected]> 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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Thomas Huth <[email protected]> Message-ID: <[email protected]> --- 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
