diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-21 15:51:54 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-21 15:51:54 +0100 |
commit | 712cb734bda0227861630b365a97dfec88798c3b (patch) | |
tree | f0e79f0b144395b5a02d32de09dca263e669ee53 /Lib/test/test_logging.py | |
parent | 5255b86fba38a5e22a0991772a3c1bbf3edd66cc (diff) | |
download | cpython-712cb734bda0227861630b365a97dfec88798c3b.tar.gz cpython-712cb734bda0227861630b365a97dfec88798c3b.zip |
Issue #20037: Avoid crashes when doing text I/O late at interpreter shutdown.
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r-- | Lib/test/test_logging.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index ce3f84cf89d..3765f36aa6d 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({}) |