registry: Better explain String.__str__

This commit is contained in:
Valentin Lorentz 2021-12-03 18:03:27 +01:00
parent fba5ed5fa4
commit ef0cd48bd1

View File

@ -660,7 +660,11 @@ class String(Value):
return any([x not in self._printable for x in s]) and s.strip() != s return any([x not in self._printable for x in s]) and s.strip() != s
def __str__(self): def __str__(self):
s = Value.__call__(self) # Don't call self(), it might be overridden # Don't call self(), it might be overridden; and this can cause various
# problem (eg. registry.Json.__call__ returns non-strings,
# conf.Directory.__call__ has filesystem side-effects that we shouldn't
# trigger here, etc.)
s = Value.__call__(self)
if self._needsQuoting(s): if self._needsQuoting(s):
s = repr(s) s = repr(s)
return s return s