|
1 | | -# Copyright 2001-2022 by Vinay Sajip. All Rights Reserved. |
| 1 | +# Copyright 2001-2026 by Vinay Sajip. All Rights Reserved. |
2 | 2 | # |
3 | 3 | # Permission to use, copy, modify, and distribute this software and its |
4 | 4 | # documentation for any purpose and without fee is hereby granted, |
|
16 | 16 |
|
17 | 17 | """Test harness for the logging module. Run all tests. |
18 | 18 |
|
19 | | -Copyright (C) 2001-2022 Vinay Sajip. All Rights Reserved. |
| 19 | +Copyright (C) 2001-2026 Vinay Sajip. All Rights Reserved. |
20 | 20 | """ |
21 | 21 | import logging |
22 | 22 | import logging.handlers |
@@ -800,6 +800,36 @@ def lock_holder_thread_fn(): |
800 | 800 |
|
801 | 801 | support.wait_process(pid, exitcode=0) |
802 | 802 |
|
| 803 | + def test_135683(self): |
| 804 | + # See gh-135683 |
| 805 | + |
| 806 | + def tester(): |
| 807 | + with tempfile.TemporaryDirectory(prefix='test_logging_') as tmp: |
| 808 | + tmp_dir = pathlib.Path(tmp) |
| 809 | + dir_path = tmp_dir / 'dir' |
| 810 | + link_path = tmp_dir / 'link' |
| 811 | + dir_path.mkdir() |
| 812 | + link_path.symlink_to(dir_path) |
| 813 | + r = logging.makeLogRecord({'msg': 'Test'}) |
| 814 | + h = logging.handlers.WatchedFileHandler(link_path / 'file.log') |
| 815 | + m = Mock() |
| 816 | + h.handleError = m |
| 817 | + try: |
| 818 | + h.handle(r) |
| 819 | + m.assert_not_called() |
| 820 | + shutil.rmtree(dir_path) |
| 821 | + h.handle(r) |
| 822 | + m.assert_called() |
| 823 | + finally: |
| 824 | + h.close() |
| 825 | + |
| 826 | + old_raiseExceptions = logging.raiseExceptions |
| 827 | + try: |
| 828 | + for test_value in (False, True): |
| 829 | + logging.raiseExceptions = test_value |
| 830 | + tester() |
| 831 | + finally: |
| 832 | + logging.raiseExceptions = old_raiseExceptions |
803 | 833 |
|
804 | 834 | class BadStream(object): |
805 | 835 | def write(self, data): |
@@ -4439,7 +4469,6 @@ def test_queue_listener_with_multiple_handlers(self): |
4439 | 4469 |
|
4440 | 4470 | if hasattr(logging.handlers, 'QueueListener'): |
4441 | 4471 | import multiprocessing |
4442 | | - from unittest.mock import patch |
4443 | 4472 |
|
4444 | 4473 | @skip_if_tsan_fork |
4445 | 4474 | @threading_helper.requires_working_threading() |
|
0 commit comments