This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients David Wang, vinay.sajip, xtreak
Date 2019-06-13.10:01:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560420087.63.0.880956683612.issue37258@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-06-13 10:01:27xtreaksetrecipients: + xtreak, vinay.sajip, David Wang
2019-06-13 10:01:27xtreaksetmessageid: <1560420087.63.0.880956683612.issue37258@roundup.psfhosted.org>
2019-06-13 10:01:27xtreaklinkissue37258 messages
2019-06-13 10:01:27xtreakcreate