Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1d4fbf

Browse files
committed
Issue #22386: fixed regression.
1 parent 42d67af commit d1d4fbf

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

Doc/library/logging.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,8 @@ functions.
10521052
.. versionchanged:: 3.4
10531053
In Python versions earlier than 3.4, this function could also be passed a
10541054
text level, and would return the corresponding numeric value of the level.
1055-
This undocumented behaviour was a mistake, and has been removed in Python
1056-
3.4.
1055+
This undocumented behaviour was considered a mistake, and was removed in
1056+
Python 3.4, but reinstated in 3.4.2 due to retain backward compatibility.
10571057

10581058
.. function:: makeLogRecord(attrdict)
10591059

Lib/logging/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def getLevelName(level):
129129
130130
Otherwise, the string "Level %s" % level is returned.
131131
"""
132-
return _levelToName.get(level, ("Level %s" % level))
132+
# See Issue #22386 for the reason for this convoluted expression
133+
return _levelToName.get(level, _nameToLevel.get(level, ("Level %s" % level)))
133134

134135
def addLevelName(level, levelName):
135136
"""

Lib/test/test_logging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ def test_nested_with_virtual_parent(self):
313313
('INF.BADPARENT', 'INFO', '4'),
314314
])
315315

316+
def test_regression_22386(self):
317+
"""See issue #22386 for more information."""
318+
self.assertEqual(logging.getLevelName('INFO'), logging.INFO)
319+
self.assertEqual(logging.getLevelName(logging.INFO), 'INFO')
316320

317321
class BasicFilterTest(BaseTest):
318322

0 commit comments

Comments
 (0)