summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMasen Furer <m_github@0x26.net>2023-01-16 09:05:15 -0800
committerGitHub <noreply@github.com>2023-01-16 09:05:15 -0800
commit0006a12d5d8aaf07e97dc797aa5c512b59202879 (patch)
tree165ae8f4a9bd15a092f1b5be8e270b2046224316 /src
parent2d46a1e1efe3504043441d5cb5fdec8c1c7f8c3e (diff)
downloadtox-git-0006a12d5d8aaf07e97dc797aa5c512b59202879.tar.gz
Fix regression with multiple env substitutions for the same key (#2873)
Fix https://github.com/tox-dev/tox/issues/2869
Diffstat (limited to 'src')
-rw-r--r--src/tox/config/loader/ini/replace.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/tox/config/loader/ini/replace.py b/src/tox/config/loader/ini/replace.py
index d856277c..40730ca5 100644
--- a/src/tox/config/loader/ini/replace.py
+++ b/src/tox/config/loader/ini/replace.py
@@ -178,29 +178,32 @@ class Replacer:
return "".join(self(value))
def _replace_match(self, value: MatchExpression) -> str:
+ # use a copy of conf_args so any changes from this replacement do NOT
+ # affect adjacent substitutions (#2869)
+ conf_args = self.conf_args.copy()
of_type, *args = flattened_args = [self.join(arg) for arg in value.expr]
if of_type == "/":
replace_value: str | None = os.sep
elif of_type == "" and args == [""]:
replace_value = os.pathsep
elif of_type == "env":
- replace_value = replace_env(self.conf, args, self.conf_args)
+ replace_value = replace_env(self.conf, args, conf_args)
elif of_type == "tty":
replace_value = replace_tty(args)
elif of_type == "posargs":
- replace_value = replace_pos_args(self.conf, args, self.conf_args)
+ replace_value = replace_pos_args(self.conf, args, conf_args)
else:
replace_value = replace_reference(
self.conf,
self.loader,
ARG_DELIMITER.join(flattened_args),
- self.conf_args,
+ conf_args,
)
if replace_value is not None:
needs_expansion = any(isinstance(m, MatchExpression) for m in find_replace_expr(replace_value))
if needs_expansion:
try:
- return replace(self.conf, self.loader, replace_value, self.conf_args, self.depth + 1)
+ return replace(self.conf, self.loader, replace_value, conf_args, self.depth + 1)
except MatchRecursionError as err:
LOGGER.warning(str(err))
return replace_value