[Python-checkins] Updated incorrect level-setting code to use setLevel(). (GH-16325) (GH-16327)
Vinay Sajip
webhook-mailer at python.org
Sat Sep 21 23:26:40 EDT 2019
https://github.com/python/cpython/commit/fe9089a08b6dd6dd1ba8b238afc2fc4dfaac689e
commit: fe9089a08b6dd6dd1ba8b238afc2fc4dfaac689e
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: 2019-09-22T04:26:37+01:00
summary:
Updated incorrect level-setting code to use setLevel(). (GH-16325) (GH-16327)
(cherry picked from commit 1d094af716e8ce5e5710e1dfbce7832ba333be55)
files:
M Lib/logging/config.py
M Lib/test/test_logging.py
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index cfd93116eedd..9dd35e11aab3 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2019 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@@ -19,7 +19,7 @@
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
by Apache's log4j system.
-Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
@@ -173,9 +173,10 @@ def _handle_existing_loggers(existing, child_loggers, disable_existing):
for log in existing:
logger = root.manager.loggerDict[log]
if log in child_loggers:
- logger.level = logging.NOTSET
- logger.handlers = []
- logger.propagate = True
+ if not isinstance(logger, logging.PlaceHolder):
+ logger.setLevel(logging.NOTSET)
+ logger.handlers = []
+ logger.propagate = True
else:
logger.disabled = disable_existing
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 7399bb362f6e..37655a5ccc40 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -4315,7 +4315,7 @@ def cleanup(self):
logging._handlers.clear()
logging._handlers.update(self.saved_handlers)
logging._handlerList[:] = self.saved_handler_list
- logging.root.level = self.original_logging_level
+ logging.root.setLevel(self.original_logging_level)
def test_no_kwargs(self):
logging.basicConfig()
More information about the Python-checkins
mailing list