diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index abc4b0cbc20..c5988c93682 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1096,6 +1096,8 @@ class Manager(object): placeholder to now point to the logger. """ rv = None + if not isinstance(name, str): + raise ValueError('A logger name must be a string') _acquireLock() try: if name in self.loggerDict: diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 7c8bab51f68..64c0653efaf 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -310,6 +310,8 @@ class BuiltinLevelsTest(BaseTest): ('INF.BADPARENT', 'INFO', '4'), ]) + def test_invalid_name(self): + self.assertRaises(ValueError, logging.getLogger, any) class BasicFilterTest(BaseTest):