summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-04-13 09:17:03 (GMT)
committerGitHub <noreply@github.com>2021-04-13 09:17:03 (GMT)
commitc2b7a66b91cdb96fbfdb160f96797208ddc5e436 (patch)
treefd8a4bcca046f1ed4fc803c8534d246522a6fb2b /Lib/logging
parenta4833883c9b81b6b272cc7c5b67fa1658b65304c (diff)
downloadcpython-c2b7a66b91cdb96fbfdb160f96797208ddc5e436.zip
cpython-c2b7a66b91cdb96fbfdb160f96797208ddc5e436.tar.gz
cpython-c2b7a66b91cdb96fbfdb160f96797208ddc5e436.tar.bz2
bpo-43731: Add an `encoding` parameter to logging.fileConfig() (GH-25273)
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/config.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index fd3aded..3bc63b7 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -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)