summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index ce3f84c..3765f36 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -41,6 +41,7 @@ import socket
import struct
import sys
import tempfile
+from test.script_helper import assert_python_ok
from test.support import (captured_stdout, run_with_locale, run_unittest,
patch, requires_zlib, TestHandler, Matcher)
import textwrap
@@ -3397,6 +3398,25 @@ class ModuleLevelMiscTest(BaseTest):
logging.setLoggerClass(logging.Logger)
self.assertEqual(logging.getLoggerClass(), logging.Logger)
+ def test_logging_at_shutdown(self):
+ # Issue #20037
+ code = """if 1:
+ import logging
+
+ class A:
+ def __del__(self):
+ try:
+ raise ValueError("some error")
+ except Exception:
+ logging.exception("exception in __del__")
+
+ a = A()"""
+ rc, out, err = assert_python_ok("-c", code)
+ err = err.decode()
+ self.assertIn("exception in __del__", err)
+ self.assertIn("ValueError: some error", err)
+
+
class LogRecordTest(BaseTest):
def test_str_rep(self):
r = logging.makeLogRecord({})