Skip to content

Commit 495d139

Browse files
committed
Don't attempt to parse dicts if not replacing
When reading in the config and processing dict content we were splitting on = assuming we would always have key = value pairs. However in the case where we don't want to replace because the testenv will not be used this can result in ValueErrors as substitution variables are not string key = value pairs. Avoid all this by only attempting to process dict key = values if we are replacing in the first place. Otherwise the content isn't needed and we just return the default value or empty dict. This should fix tox-dev#595
1 parent a766e06 commit 495d139

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tox/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,16 +957,17 @@ def getlist(self, name, sep="\n"):
957957

958958
def getdict(self, name, default=None, sep="\n", replace=True):
959959
value = self.getstring(name, None, replace=replace)
960-
return self._getdict(value, default=default, sep=sep)
960+
return self._getdict(value, default=default, sep=sep, replace=replace)
961961

962962
def getdict_setenv(self, name, default=None, sep="\n", replace=True):
963963
value = self.getstring(name, None, replace=replace, crossonly=True)
964-
definitions = self._getdict(value, default=default, sep=sep)
964+
definitions = self._getdict(value, default=default, sep=sep,
965+
replace=replace)
965966
self._setenv = SetenvDict(definitions, reader=self)
966967
return self._setenv
967968

968-
def _getdict(self, value, default, sep):
969-
if value is None:
969+
def _getdict(self, value, default, sep, replace=True):
970+
if value is None or not replace:
970971
return default or {}
971972

972973
d = {}

0 commit comments

Comments
 (0)