comparison configmix/config.py @ 251:2a8dcab2de8c

Do not implicitely convert a configuration value to text if the value is the result of just a variable expansion. This is technically a breaking change. But no known client code uses the old behaviour.
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 07 Jul 2020 22:21:27 +0200
parents ff964825a75a
children eed16a1ec8f3
comparison
equal deleted inserted replaced
250:ff964825a75a 251:2a8dcab2de8c
217 UserWarning, 217 UserWarning,
218 stacklevel=1) 218 stacklevel=1)
219 raise 219 raise
220 if varvalue is None: 220 if varvalue is None:
221 varvalue = u("") 221 varvalue = u("")
222 #
223 # Dont apply and type conversions to str if the whole `s` is
224 # just one expansion
225 #
226 if (start == 0) and (end + 2 == len(s)):
227 return varvalue
222 replaced = s[:start] + u(str(varvalue)) 228 replaced = s[:start] + u(str(varvalue))
223 s = replaced + s[end+2:] 229 s = replaced + s[end+2:]
224 # don't re-evaluate because `self.getvar_s()` expands already 230 # don't re-evaluate because `self.getvar_s()` expands already
225 start = s.find(self._STARTTOK, len(replaced)) 231 start = s.find(self._STARTTOK, len(replaced))
226 return s 232 return s