From c0d15f54edaf76cfac31fb725cb3d43d00a14724 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 8 Aug 2020 20:26:57 +0200 Subject: Merging upstream version 3.2.0. Signed-off-by: Daniel Baumann --- cfgv.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cfgv.py') diff --git a/cfgv.py b/cfgv.py index 64c2380..f0b9eff 100644 --- a/cfgv.py +++ b/cfgv.py @@ -395,10 +395,13 @@ 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: -- cgit v1.2.3