[Python-checkins] cpython (merge 3.4 -> default): Closes #22386: merged fix from 3.4.

vinay.sajip python-checkins at python.org
Fri Sep 12 00:09:02 CEST 2014


http://hg.python.org/cpython/rev/070fed5b7b9d
changeset:   92408:070fed5b7b9d
parent:      92405:9f1d3e6e6ce6
parent:      92407:a4c5effb8698
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Thu Sep 11 23:08:48 2014 +0100
summary:
  Closes #22386: merged fix from 3.4.

files:
  Doc/library/logging.rst  |  4 ++--
  Lib/logging/__init__.py  |  3 ++-
  Lib/test/test_logging.py |  4 ++++
  3 files changed, 8 insertions(+), 3 deletions(-)


diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -1052,8 +1052,8 @@
    .. versionchanged:: 3.4
       In Python versions earlier than 3.4, this function could also be passed a
       text level, and would return the corresponding numeric value of the level.
-      This undocumented behaviour was a mistake, and has been removed in Python
-      3.4.
+      This undocumented behaviour was considered a mistake, and was removed in
+      Python 3.4, but reinstated in 3.4.2 due to retain backward compatibility.
 
 .. function:: makeLogRecord(attrdict)
 
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -129,7 +129,8 @@
 
     Otherwise, the string "Level %s" % level is returned.
     """
-    return _levelToName.get(level, ("Level %s" % level))
+    # See Issue #22386 for the reason for this convoluted expression
+    return _levelToName.get(level, _nameToLevel.get(level, ("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
@@ -307,6 +307,10 @@
             ('INF.BADPARENT', 'INFO', '4'),
         ])
 
+    def test_regression_22386(self):
+        """See issue #22386 for more information."""
+        self.assertEqual(logging.getLevelName('INFO'), logging.INFO)
+        self.assertEqual(logging.getLevelName(logging.INFO), 'INFO')
 
 class BasicFilterTest(BaseTest):
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list