summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-21 20:27:00 -0700
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2019-09-22 04:27:00 +0100
commit6641a109fba8489acf2762b2ac2e8c2c20c3a640 (patch)
treed2df3c9ef6abc0f661fd1d0667a75928d1a42b8e
parentDoc: Fix spelling errors of 'initial' in enum.py (GH-16314) (diff)
downloadcpython-6641a109fba8489acf2762b2ac2e8c2c20c3a640.tar.gz
cpython-6641a109fba8489acf2762b2ac2e8c2c20c3a640.tar.bz2
cpython-6641a109fba8489acf2762b2ac2e8c2c20c3a640.zip
Updated incorrect level-setting code to use setLevel(). (GH-16325) (GH-16326)
(cherry picked from commit 1d094af716e8ce5e5710e1dfbce7832ba333be55)
-rw-r--r--Lib/logging/config.py11
-rw-r--r--Lib/test/test_logging.py2
2 files changed, 7 insertions, 6 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index fa1a398aee2..f58be930893 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 @@ Configuration functions for the logging package for Python. The core package
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 13393cd8b37..546cea98c1e 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -4020,7 +4020,7 @@ class BasicConfigTest(unittest.TestCase):
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()