Skip to content

Commit c8149bc

Browse files
committed
backport python#104701
1 parent 687317a commit c8149bc

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Doc/library/logging.config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in
8888
configuration).
8989

9090
It will raise :exc:`FileNotFoundError` if the file
91-
doesn't exist and :exc:`ValueError` if the file is invalid or
91+
doesn't exist and :exc:`RuntimeError` if the file is invalid or
9292
empty.
9393

9494
:param fname: A filename, or a file-like object, or an instance derived

Lib/logging/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=Non
6464
if not os.path.exists(fname):
6565
raise FileNotFoundError(f"{fname} doesn't exist")
6666
elif not os.path.getsize(fname):
67-
raise ValueError(f'{fname} is an empty file')
67+
raise RuntimeError(f'{fname} is an empty file')
6868

6969
if isinstance(fname, configparser.RawConfigParser):
7070
cp = fname
@@ -77,7 +77,7 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=Non
7777
encoding = io.text_encoding(encoding)
7878
cp.read(fname, encoding=encoding)
7979
except configparser.ParsingError as e:
80-
raise ValueError(f'{fname} is invalid: {e}')
80+
raise RuntimeError(f'{fname} is invalid: {e}')
8181

8282
formatters = _create_formatters(cp)
8383

Lib/test/test_logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,12 +1670,12 @@ def test_exception_if_confg_file_is_invalid(self):
16701670
"""
16711671

16721672
file = io.StringIO(textwrap.dedent(test_config))
1673-
self.assertRaises(ValueError, logging.config.fileConfig, file)
1673+
self.assertRaises(RuntimeError, logging.config.fileConfig, file)
16741674

16751675
def test_exception_if_confg_file_is_empty(self):
16761676
fd, fn = tempfile.mkstemp(prefix='test_empty_', suffix='.ini')
16771677
os.close(fd)
1678-
self.assertRaises(ValueError, logging.config.fileConfig, fn)
1678+
self.assertRaises(RuntimeError, logging.config.fileConfig, fn)
16791679
os.remove(fn)
16801680

16811681
def test_exception_if_config_file_does_not_exist(self):

0 commit comments

Comments
 (0)