From: Pascal Obry Date: Thu, 2 May 2024 13:32:09 +0000 (+0200) Subject: salomeContext.py: Rework routine removeFromVariable for Python < 3.9. X-Git-Tag: emc2p_2.0.0-rc2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=328226aa6c341484466f5dd9056bb543ac8e91a5;p=modules%2Fkernel.git salomeContext.py: Rework routine removeFromVariable for Python < 3.9. --- 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