do not crash when config.yml is 0 bytes or empty of data

This commit is contained in:
Hans-Christoph Steiner 2021-04-08 12:44:45 +02:00
parent 5267699d81
commit 40c77892a2
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
2 changed files with 13 additions and 0 deletions

View file

@ -362,6 +362,8 @@ def read_config(opts=None):
logging.debug(_("Reading '{config_file}'").format(config_file=config_file))
with open(config_file, encoding='utf-8') as fp:
config = yaml.safe_load(fp)
if not config:
config = {}
elif os.path.exists(old_config_file):
logging.warning(_("""{oldfile} is deprecated, use {newfile}""")
.format(oldfile=old_config_file, newfile=config_file))