summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPreston Landers <planders@utexas.edu>2017-08-02 20:44:28 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-08-02 20:44:28 (GMT)
commit6ea56d2ebcae69257f8dd7af28c357b25bf394c3 (patch)
tree7e4c607a686f94143ef8ceba102df888e35480ea /Lib
parentde34cbe9cdaaf7b85fed86f99c2fd071e1a7b1d2 (diff)
downloadcpython-6ea56d2ebcae69257f8dd7af28c357b25bf394c3.zip
cpython-6ea56d2ebcae69257f8dd7af28c357b25bf394c3.tar.gz
cpython-6ea56d2ebcae69257f8dd7af28c357b25bf394c3.tar.bz2
bpo-31080: Allowed logging.config.fileConfig() to accept both args and kwargs. (GH-2979)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/config.py6
-rw-r--r--Lib/test/test_logging.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index d692514..b3f4e28 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -143,9 +143,11 @@ def _install_handlers(cp, formatters):
klass = eval(klass, vars(logging))
except (AttributeError, NameError):
klass = _resolve(klass)
- args = section["args"]
+ args = section.get("args", '()')
args = eval(args, vars(logging))
- h = klass(*args)
+ kwargs = section.get("kwargs", '{}')
+ kwargs = eval(kwargs, vars(logging))
+ h = klass(*args, **kwargs)
if "level" in section:
level = section["level"]
h.setLevel(level)
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 36ea072..a91cfd4 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -1273,7 +1273,7 @@ class ConfigFileTest(BaseTest):
datefmt=
"""
- # config7 adds a compiler logger.
+ # config7 adds a compiler logger, and uses kwargs instead of args.
config7 = """
[loggers]
keys=root,parser,compiler
@@ -1304,7 +1304,7 @@ class ConfigFileTest(BaseTest):
class=StreamHandler
level=NOTSET
formatter=form1
- args=(sys.stdout,)
+ kwargs={'stream': sys.stdout,}
[formatter_form1]
format=%(levelname)s ++ %(message)s