From a5dbe1f1ffeb5fda307f93da9b4258d11e97cf8b Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 16 Nov 2023 15:34:21 +0300 Subject: [PATCH 1/2] gh-111800: Fix `test_recursive_repr` from `test_io` under WASI --- Lib/test/test_io.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index ab3389215e93d0..35df8e3dd1d88c 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1234,11 +1234,9 @@ def test_recursive_repr(self): # Issue #25455 raw = self.MockRawIO() b = self.tp(raw) - with support.swap_attr(raw, 'name', b): - try: + with support.swap_attr(raw, 'name', b), support.infinite_recursion(25): + with self.assertRaises(RuntimeError): repr(b) # Should not crash - except RuntimeError: - pass def test_flush_error_on_close(self): # Test that buffered file is closed despite failed flush From f4eb0681823cd7bc9a2e8d2163c10136b44cd8dd Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 16 Nov 2023 21:51:40 +0300 Subject: [PATCH 2/2] Fix the second one as well --- Lib/test/test_io.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 35df8e3dd1d88c..09cced9baef99b 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -2799,11 +2799,9 @@ def test_recursive_repr(self): # Issue #25455 raw = self.BytesIO() t = self.TextIOWrapper(raw, encoding="utf-8") - with support.swap_attr(raw, 'name', t): - try: + with support.swap_attr(raw, 'name', t), support.infinite_recursion(25): + with self.assertRaises(RuntimeError): repr(t) # Should not crash - except RuntimeError: - pass def test_line_buffering(self): r = self.BytesIO()