Issue #292Merged fixes from 3.5.

This commit is contained in:
Vinay Sajip 2017-01-11 17:41:28 +00:00
commit a861d48817
2 changed files with 16 additions and 3 deletions

View File

@ -131,9 +131,14 @@ def getLevelName(level):
Otherwise, the string "Level %s" % level is returned. Otherwise, the string "Level %s" % level is returned.
""" """
# See Issues #22386 and #27937 for why it's this way # See Issues #22386, #27937 and #29220 for why it's this way
return (_levelToName.get(level) or _nameToLevel.get(level) or result = _levelToName.get(level)
"Level %s" % level) 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): def addLevelName(level, levelName):
""" """

View File

@ -313,6 +313,14 @@ class BuiltinLevelsTest(BaseTest):
fatal = logging.getLevelName('FATAL') fatal = logging.getLevelName('FATAL')
self.assertEqual(fatal, logging.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): class BasicFilterTest(BaseTest):
"""Test the bundled Filter class.""" """Test the bundled Filter class."""