bpo-43731: Add an encoding parameter to logging.fileConfig() (GH-25273)

This commit is contained in:
Inada Naoki 2021-04-13 18:17:03 +09:00 committed by GitHub
parent a4833883c9
commit c2b7a66b91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -48,7 +48,7 @@ RESET_ERROR = errno.ECONNRESET
# _listener holds the server object doing the listening
_listener = None
def fileConfig(fname, defaults=None, disable_existing_loggers=True):
def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=None):
"""
Read the logging configuration from a ConfigParser-format file.
@ -66,7 +66,8 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
if hasattr(fname, 'readline'):
cp.read_file(fname)
else:
cp.read(fname)
encoding = io.text_encoding(encoding)
cp.read(fname, encoding=encoding)
formatters = _create_formatters(cp)