[Python-checkins] cpython (2.7): Closes #13661: Check added for type of logger name.

vinay.sajip python-checkins at python.org
Mon Nov 7 09:55:03 CET 2011


http://hg.python.org/cpython/rev/5f3b7528b144
changeset:   73415:5f3b7528b144
branch:      2.7
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Mon Nov 07 08:49:16 2011 +0000
summary:
  Closes #13661: Check added for type of logger name.

files:
  Lib/logging/__init__.py  |  2 ++
  Lib/test/test_logging.py |  2 ++
  2 files changed, 4 insertions(+), 0 deletions(-)


diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1007,6 +1007,8 @@
         placeholder to now point to the logger.
         """
         rv = None
+        if not isinstance(name, basestring):
+            raise ValueError('A logger name must be string or Unicode')
         if isinstance(name, unicode):
             name = name.encode('utf-8')
         _acquireLock()
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
@@ -272,6 +272,8 @@
             ('INF.BADPARENT', 'INFO', '4'),
         ])
 
+    def test_invalid_name(self):
+        self.assertRaises(ValueError, logging.getLogger, any)
 
 class BasicFilterTest(BaseTest):
 

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


More information about the Python-checkins mailing list