1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-12-17 06:35:42 +07:00

Improve error handling of bad config files

Related: #824
This commit is contained in:
pukkandan
2022-06-18 09:17:45 +05:30
parent bf1824b391
commit 44a6fcff39
2 changed files with 12 additions and 6 deletions

View File

@@ -5420,6 +5420,8 @@ def read_file(filename, default=[]):
# FIXME: https://github.com/ytdl-org/youtube-dl/commit/dfe5fa49aed02cf36ba9f743b11b0903554b5e56
contents = optionf.read()
res = shlex.split(contents, comments=True)
except Exception as err:
raise ValueError(f'Unable to parse "{filename}": {err}')
finally:
optionf.close()
return res