[Python-checkins] cpython (3.5): Fixes #27937: optimise code used in all logging calls.

vinay.sajip python-checkins at python.org
Sat Sep 3 11:55:44 EDT 2016


https://hg.python.org/cpython/rev/e4b6faf22e8d
changeset:   103018:e4b6faf22e8d
branch:      3.5
parent:      103012:c3c4d8e4ca1a
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Sat Sep 03 16:50:09 2016 +0100
summary:
  Fixes #27937: optimise code used in all logging calls.

files:
  Lib/logging/__init__.py |  9 +++++----
  1 files changed, 5 insertions(+), 4 deletions(-)


diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -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 @@
 
     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):
     """

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list