From 328226aa6c341484466f5dd9056bb543ac8e91a5 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Thu, 2 May 2024 15:32:09 +0200 Subject: [PATCH] salomeContext.py: Rework routine removeFromVariable for Python < 3.9. --- bin/salomeContext.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 93a74d457..d59f2cad6 100755 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -242,8 +242,14 @@ class SalomeContext: if env == value: env = '' else: - env = env.removeprefix(value + separator) - env = env.removesuffix(separator + value) + # env = env.removeprefix(value + separator) (Python >= 3.9) + str = value + separator + if env.startswith(str): + env = env[len(str):] + # env = env.removesuffix(separator + value) (Python >= 3.9) + str = separator + value + if env.endswith(str): + env = env[:-len(str)] env = env.replace(separator + value + separator, ':') os.environ[name] = env -- 2.39.2