From ec0be347e6deea20381437ff0ffeec15acc6ddc2 Mon Sep 17 00:00:00 2001 From: Guillaume SUTRA Date: Tue, 31 Jan 2023 15:28:52 +0100 Subject: [PATCH] fix ResourceWarning: unclosed file INSTALL/KERNEL/bin/salome/VERSION --- src/Utils/Utils_Identity.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Utils/Utils_Identity.py b/src/Utils/Utils_Identity.py index 596317dab..be8991e49 100644 --- a/src/Utils/Utils_Identity.py +++ b/src/Utils/Utils_Identity.py @@ -77,11 +77,10 @@ def getapplipath(): return os.environ.get("APPLI",".salome_"+versnb) try: - file = open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r") - s = file.readline() + with open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r") as file: + s = file.readline() versnb = string.strip(string.split(s, ":")[1]) dirname=".salome_"+versnb - file.close() except Exception: versnb = "" dirname=".salome" -- 2.39.2