]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111800: Fix `test_recursive_repr` from `test_io` under WASI to not recurse so...
authorNikita Sobolev <mail@sobolevn.me>
Thu, 16 Nov 2023 19:47:38 +0000 (22:47 +0300)
committerGitHub <noreply@github.com>
Thu, 16 Nov 2023 19:47:38 +0000 (11:47 -0800)
Lib/test/test_io.py

index ab3389215e93d0a9da12daaaf8bdf9edc5b660d0..09cced9baef99bb98cc6a4c972b3e95401576811 100644 (file)
@@ -1234,11 +1234,9 @@ class CommonBufferedTests:
         # 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
@@ -2801,11 +2799,9 @@ class TextIOWrapperTest(unittest.TestCase):
         # 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()