Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab7b0a0

Browse files
committed
Fixes #27937: optimise code used in all logging calls.
1 parent f0f1c23 commit ab7b0a0

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Lib/logging/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2015 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2016 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,
@@ -18,7 +18,7 @@
1818
Logging package for Python. Based on PEP 282 and comments thereto in
1919
comp.lang.python.
2020
21-
Copyright (C) 2001-2015 Vinay Sajip. All Rights Reserved.
21+
Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved.
2222
2323
To use, simply 'import logging' and log away!
2424
"""
@@ -129,8 +129,9 @@ def getLevelName(level):
129129
130130
Otherwise, the string "Level %s" % level is returned.
131131
"""
132-
# See Issue #22386 for the reason for this convoluted expression
133-
return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % level)))
132+
# See Issues #22386 and #27937 for why it's this way
133+
return (_levelToName.get(level) or _nameToLevel.get(level) or
134+
"Level %s" % level)
134135

135136
def addLevelName(level, levelName):
136137
"""

0 commit comments

Comments
 (0)