[Python-checkins] cpython (merge 3.6 -> default): Issue #29220: Merged fixes from 3.6.
vinay.sajip
python-checkins at python.org
Wed Jan 11 12:44:18 EST 2017
https://hg.python.org/cpython/rev/a76eed0baa0f
changeset: 106094:a76eed0baa0f
parent: 106091:4e29c7f2b3e5
parent: 106093:aad038e8dfef
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Wed Jan 11 17:44:07 2017 +0000
summary:
Issue #29220: Merged fixes from 3.6.
files:
Lib/logging/__init__.py | 11 ++++++-----
Lib/test/test_logging.py | 8 ++++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -133,11 +133,12 @@
"""
# See Issues #22386, #27937 and #29220 for why it's this way
result = _levelToName.get(level)
- if result is None:
- result = _nameToLevel.get(level)
- if result is None:
- result = "Level %s" % level
- return result
+ if result is not None:
+ return result
+ result = _nameToLevel.get(level)
+ if result is not None:
+ return result
+ return "Level %s" % level
def addLevelName(level, levelName):
"""
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -319,6 +319,14 @@
fatal = logging.getLevelName('FATAL')
self.assertEqual(fatal, logging.FATAL)
+ def test_regression_29220(self):
+ """See issue #29220 for more information."""
+ logging.addLevelName(logging.INFO, '')
+ self.addCleanup(logging.addLevelName, logging.INFO, 'INFO')
+ self.assertEqual(logging.getLevelName(logging.INFO), '')
+ self.assertEqual(logging.getLevelName(logging.NOTSET), 'NOTSET')
+ self.assertEqual(logging.getLevelName('NOTSET'), logging.NOTSET)
+
class BasicFilterTest(BaseTest):
"""Test the bundled Filter class."""
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list