]> granicus.if.org Git - python/commitdiff
Fixes #27937: optimise code used in all logging calls.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 3 Sep 2016 15:50:09 +0000 (16:50 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Sat, 3 Sep 2016 15:50:09 +0000 (16:50 +0100)
Lib/logging/__init__.py

index a7bd890e3cc6d2ca95485aa2064a35341494ca1e..22744e18b0733869b21373daa5c14bb1478cc2c9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2001-2015 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2016 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,
@@ -18,7 +18,7 @@
 Logging package for Python. Based on PEP 282 and comments thereto in
 comp.lang.python.
 
-Copyright (C) 2001-2015 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2016 Vinay Sajip. All Rights Reserved.
 
 To use, simply 'import logging' and log away!
 """
@@ -129,8 +129,9 @@ def getLevelName(level):
 
     Otherwise, the string "Level %s" % level is returned.
     """
-    # See Issue #22386 for the reason for this convoluted expression
-    return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % level)))
+    # See Issues #22386 and #27937 for why it's this way
+    return (_levelToName.get(level) or _nameToLevel.get(level) or
+            "Level %s" % level)
 
 def addLevelName(level, levelName):
     """