From 74ab3440bad1b97e39fb5adf992e555ba26001d1 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 7 Nov 2011 08:49:16 +0000 Subject: [PATCH] Closes #13661: Check added for type of logger name. --- Lib/logging/__init__.py | 2 ++ Lib/test/test_logging.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index f6af6057e6c..a0c4cb7233c 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1007,6 +1007,8 @@ class Manager(object): 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 index 0760a6a07b2..b2d0a2bda62 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -272,6 +272,8 @@ class BuiltinLevelsTest(BaseTest): ('INF.BADPARENT', 'INFO', '4'), ]) + def test_invalid_name(self): + self.assertRaises(ValueError, logging.getLogger, any) class BasicFilterTest(BaseTest):