mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-103606: raise RuntimeError if config file is invalid or empty (#104701)
(this adjusts new code) raise RuntimeError if provided config file is invalid or empty, not ValueError.
This commit is contained in:
parent
27a68be77f
commit
12f1581b0c
3 changed files with 6 additions and 6 deletions
|
@ -65,7 +65,7 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=Non
|
|||
if not os.path.exists(fname):
|
||||
raise FileNotFoundError(f"{fname} doesn't exist")
|
||||
elif not os.path.getsize(fname):
|
||||
raise ValueError(f'{fname} is an empty file')
|
||||
raise RuntimeError(f'{fname} is an empty file')
|
||||
|
||||
if isinstance(fname, configparser.RawConfigParser):
|
||||
cp = fname
|
||||
|
@ -78,7 +78,7 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=Non
|
|||
encoding = io.text_encoding(encoding)
|
||||
cp.read(fname, encoding=encoding)
|
||||
except configparser.ParsingError as e:
|
||||
raise ValueError(f'{fname} is invalid: {e}')
|
||||
raise RuntimeError(f'{fname} is invalid: {e}')
|
||||
|
||||
formatters = _create_formatters(cp)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue