Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:
A unittest patch for this issue. This occurs in master and 3.8 too. diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 50148dc2f2..30fd9ee37a 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -4172,6 +4172,27 @@ class ModuleLevelMiscTest(BaseTest): logging.setLoggerClass(logging.Logger) self.assertEqual(logging.getLoggerClass(), logging.Logger) + def test_subclass_logger_cache(self): + + class MyLogger(logging.getLoggerClass()): + pass + + logger = MyLogger('test') + stream = io.StringIO() + h = logging.StreamHandler(stream) + logger.addHandler(h) + + logger.setLevel(logging.DEBUG) + logger.debug("hello") + self.assertEqual(stream.getvalue().strip(), "hello") + + stream.truncate(0) + stream.seek(0) + + logger.setLevel(logging.INFO) + logger.debug("hello") + self.assertEqual(stream.getvalue(), "") + @support.requires_type_collecting def test_logging_at_shutdown(self): # Issue #20037 ---------- nosy: +xtreak versions: +Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37258> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com