summaryrefslogtreecommitdiffstats
path: root/cfgv.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-08 18:26:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-08-08 18:26:57 +0000
commitc0d15f54edaf76cfac31fb725cb3d43d00a14724 (patch)
treea12380ee8bfa8b1688d14c127accb178121f8b9d /cfgv.py
parentReleasing debian version 3.1.0-2. (diff)
downloadcfgv-c0d15f54edaf76cfac31fb725cb3d43d00a14724.tar.xz
cfgv-c0d15f54edaf76cfac31fb725cb3d43d00a14724.zip
Merging upstream version 3.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cfgv.py')
-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))