diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-01-11 17:44:07 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2017-01-11 17:44:07 (GMT) |
commit | d4f5001bac6a5d5fafb723a17cf792758fca6ea2 (patch) | |
tree | cebf267f45c23c3bf159c9623adb09688ecf737f /Lib | |
parent | 23e5b82cf74e225c57e8049907d04f6af6f8bfae (diff) | |
parent | a861d48817e2477cd0b5189787d071ff01dbe4f7 (diff) | |
download | cpython-d4f5001bac6a5d5fafb723a17cf792758fca6ea2.zip cpython-d4f5001bac6a5d5fafb723a17cf792758fca6ea2.tar.gz cpython-d4f5001bac6a5d5fafb723a17cf792758fca6ea2.tar.bz2 |
Issue #29220: Merged fixes from 3.6.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/__init__.py | 11 | ||||
-rw-r--r-- | 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 index fb866f3..49a0692 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -133,11 +133,12 @@ def getLevelName(level): """ # 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 index 6a91152..9f482e1 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -319,6 +319,14 @@ class BuiltinLevelsTest(BaseTest): 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.""" |