summaryrefslogtreecommitdiff
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2019-08-02 16:53:00 +0100
committerGitHub <noreply@github.com>2019-08-02 16:53:00 +0100
commitcb65b3a4f484ce71dcb76a918af98c7015513025 (patch)
tree7f4e08a9ed98315e4fe5d0651f9344271db928a2 /Lib/logging
parent854d0a4b98b13629252e21edaf2b785b429e5135 (diff)
downloadcpython-git-cb65b3a4f484ce71dcb76a918af98c7015513025.tar.gz
bpo-37742: Return the root logger when logging.getLogger('root') is c… (#15077)
* bpo-37742: Return the root logger when logging.getLogger('root') is called. * Added type check guard on logger name in logging.getLogger() and refined a test.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/__init__.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 645e0b3c3a..62a87a71b1 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -2024,10 +2024,9 @@ def getLogger(name=None):
If no name is specified, return the root logger.
"""
- if name:
- return Logger.manager.getLogger(name)
- else:
+ if not name or isinstance(name, str) and name == root.name:
return root
+ return Logger.manager.getLogger(name)
def critical(msg, *args, **kwargs):
"""