diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2016-09-03 15:50:09 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2016-09-03 15:50:09 (GMT) |
commit | ab7b0a03b51c01e702cbe950b387807ee832af82 (patch) | |
tree | 70bc2f7a6f86598cb37574c5cf9df51fe50385ed | |
parent | f0f1c239e4addd15180d605306a969a627cb19d5 (diff) | |
download | cpython-ab7b0a03b51c01e702cbe950b387807ee832af82.zip cpython-ab7b0a03b51c01e702cbe950b387807ee832af82.tar.gz cpython-ab7b0a03b51c01e702cbe950b387807ee832af82.tar.bz2 |
Fixes #27937: optimise code used in all logging calls.
-rw-r--r-- | Lib/logging/__init__.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index a7bd890..22744e1 100644 --- 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 @@ 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): """ |