Using slower loader for old configs.

This commit is contained in:
Roland 2026-03-10 20:21:35 -06:00 • committed by lrnselfreliance
parent da6e62ee45
commit b8eaac8ec1

View file

@ -537,7 +537,12 @@ class ConfigFile:
def read_config_file(self, file: pathlib.Path = None) -> dict:
file = file or self.get_file()
with file.open('rt') as fh:
config_data = yaml.load(fh, Loader=yaml.CSafeLoader)
try:
config_data = yaml.load(fh, Loader=yaml.CSafeLoader)
except yaml.constructor.ConstructorError:
logger_.warning(f'Config file contains Python objects, using slow loader: {file}')
fh.seek(0)
config_data = yaml.load(fh, Loader=yaml.Loader)
if not isinstance(config_data, dict):
raise InvalidConfig(f'Config file is invalid: {file}')
return config_data