From a9066298da35920402faa133f05a5b83bfea4725 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 a3b119c79..72f7d33b1 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: versnb = "" dirname=".salome" -- 2.39.2