Skip to content

Commit 6641a10

Browse files
miss-islingtonvsajip
authored andcommitted
Updated incorrect level-setting code to use setLevel(). (GH-16325) (GH-16326)
(cherry picked from commit 1d094af)
1 parent 8d4c52f commit 6641a10

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Lib/logging/config.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2016 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2019 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -19,7 +19,7 @@
1919
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
2020
by Apache's log4j system.
2121
22-
Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved.
22+
Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved.
2323
2424
To use, simply 'import logging' and log away!
2525
"""
@@ -173,9 +173,10 @@ def _handle_existing_loggers(existing, child_loggers, disable_existing):
173173
for log in existing:
174174
logger = root.manager.loggerDict[log]
175175
if log in child_loggers:
176-
logger.level = logging.NOTSET
177-
logger.handlers = []
178-
logger.propagate = True
176+
if not isinstance(logger, logging.PlaceHolder):
177+
logger.setLevel(logging.NOTSET)
178+
logger.handlers = []
179+
logger.propagate = True
179180
else:
180181
logger.disabled = disable_existing
181182

Lib/test/test_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ def cleanup(self):
40204020
logging._handlers.clear()
40214021
logging._handlers.update(self.saved_handlers)
40224022
logging._handlerList[:] = self.saved_handler_list
4023-
logging.root.level = self.original_logging_level
4023+
logging.root.setLevel(self.original_logging_level)
40244024

40254025
def test_no_kwargs(self):
40264026
logging.basicConfig()

0 commit comments

Comments
 (0)