♻ More error resilience for encoding issues in config.yaml

Normally I'd say, broken files are broken files, but since in case of an
encoding error in config.yaml the server won't come up anymore we are
erring on the side of caution here and running with errors="replace"
This commit is contained in:
Gina Häußge committed 2019-02-06 16:06:56 +01:00
1 parent 32a8646135
commit fd8788dd34
1 file changed
+2 -2
+2 -2
View File
@@ -888,7 +888,7 @@ class Settings(object):
def load(self, migrate=False):
if os.path.exists(self._configfile) and os.path.isfile(self._configfile):
with io.open(self._configfile, 'rt', encoding='utf-8') as f:
with io.open(self._configfile, 'rt', encoding='utf-8', errors='replace') as f:
try:
self._config = yaml.safe_load(f)
self._mtime = self.last_modified
@@ -927,7 +927,7 @@ class Settings(object):
if isinstance(overlay, basestring):
if os.path.exists(overlay) and os.path.isfile(overlay):
with io.open(overlay, 'rt', encoding='utf-8') as f:
with io.open(overlay, 'rt', encoding='utf-8', errors='replace') as f:
config = yaml.safe_load(f)
elif isinstance(overlay, dict):
config = overlay