summaryrefslogtreecommitdiffstats
path: root/cfgv.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-08 18:26:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-08 18:26:53 +0000
commit0be043545b0aa18aed1a585170b2ddce9cfdb968 (patch)
treed38233ecfcb80ab290c545a6c26f1f692abba809 /cfgv.py
parentAdding upstream version 3.1.0. (diff)
downloadcfgv-0be043545b0aa18aed1a585170b2ddce9cfdb968.tar.xz
cfgv-0be043545b0aa18aed1a585170b2ddce9cfdb968.zip
Adding upstream version 3.2.0.upstream/3.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cfgv.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/cfgv.py b/cfgv.py
index 64c2380..f0b9eff 100644
--- a/cfgv.py
+++ b/cfgv.py
@@ -395,11 +395,14 @@ def load_from_filename(
if not os.path.exists(filename):
raise ValidationError(f'{filename} does not exist')
- with open(filename, encoding='utf-8') as f:
- contents = f.read()
-
with validate_context(f'File {filename}'):
try:
+ with open(filename, encoding='utf-8') as f:
+ contents = f.read()
+ except UnicodeDecodeError as e:
+ raise ValidationError(str(e))
+
+ try:
data = load_strategy(contents)
except Exception as e:
raise ValidationError(str(e))