From 5879b93d587f602920623c1b9abaa392ba9b52f6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 14 Aug 2023 12:18:57 +0200 Subject: Merging upstream version 3.4.0. Signed-off-by: Daniel Baumann --- cfgv.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cfgv.py') diff --git a/cfgv.py b/cfgv.py index 701d944..27ddd98 100644 --- a/cfgv.py +++ b/cfgv.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import collections import contextlib import os.path @@ -390,12 +392,15 @@ def load_from_filename( schema, load_strategy, exc_tp=ValidationError, + *, + display_filename=None, ): + display_filename = display_filename or filename with reraise_as(exc_tp): if not os.path.isfile(filename): - raise ValidationError(f'{filename} is not a file') + raise ValidationError(f'{display_filename} is not a file') - with validate_context(f'File {filename}'): + with validate_context(f'File {display_filename}'): try: with open(filename, encoding='utf-8') as f: contents = f.read() -- cgit v1.2.3