[Python-checkins] bpo-37223, test_io: silence last 'Exception ignored in:' (GH-14029)

Victor Stinner webhook-mailer at python.org
Wed Jun 12 17:57:17 EDT 2019

commit: 913fa1c8245d1cde6edb4254f4fb965cc91786ef
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-06-12T23:57:11+02:00

bpo-37223, test_io: silence last 'Exception ignored in:' (GH-14029)

Use catch_unraisable_exception() to ignore 'Exception ignored in:'
error when the internal BufferedWriter of the BufferedRWPair is
destroyed. The C implementation doesn't give access to the
internal BufferedWriter, so just ignore the warning instead.

M Lib/test/test_io.py

diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 102679b1d342..55686d743983 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2070,6 +2070,11 @@ def writer_close():
         # Silence destructor error
         writer.close = lambda: None
+        writer = None
+        with support.catch_unraisable_exception():
+            pair = None
+            support.gc_collect()
     def test_reader_writer_close_error_on_close(self):
         def reader_close():

More information about the Python-checkins mailing list