diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index b941eab97d6b0c..7544190660871d 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1757,7 +1757,7 @@ def manager(self): return self.logger.manager @manager.setter - def set_manager(self, value): + def manager(self, value): self.logger.manager = value def __repr__(self): diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index fb0de9de046c7e..583394cc73fad0 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3982,12 +3982,25 @@ def test_nested(self): msg = 'Adapters can be nested, yo.' adapter_adapter = logging.LoggerAdapter(logger=self.adapter, extra=None) adapter_adapter.log(logging.CRITICAL, msg, self.recording) - self.assertEqual(len(self.recording.records), 1) record = self.recording.records[0] self.assertEqual(record.levelno, logging.CRITICAL) self.assertEqual(record.msg, msg) self.assertEqual(record.args, (self.recording,)) + orig_manager = adapter_adapter.manager + self.assertIs(self.adapter.manager, orig_manager) + self.assertIs(self.logger.manager, orig_manager) + temp_manager = object() + try: + adapter_adapter.manager = temp_manager + self.assertIs(adapter_adapter.manager, temp_manager) + self.assertIs(self.adapter.manager, temp_manager) + self.assertIs(self.logger.manager, temp_manager) + finally: + adapter_adapter.manager = orig_manager + self.assertIs(adapter_adapter.manager, orig_manager) + self.assertIs(self.adapter.manager, orig_manager) + self.assertIs(self.logger.manager, orig_manager) class LoggerTest(BaseTest): diff --git a/Misc/NEWS.d/next/Library/2017-10-18-16-48-09.bpo-31457._ovmzp.rst b/Misc/NEWS.d/next/Library/2017-10-18-16-48-09.bpo-31457._ovmzp.rst new file mode 100644 index 00000000000000..1a59dce39a50d9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-10-18-16-48-09.bpo-31457._ovmzp.rst @@ -0,0 +1 @@ +The ``manager`` property on LoggerAdapter objects is now properly settable.