Skip to content

Commit 4f455f4

Browse files
committed
fixup: More precise recursion errorcatching
1 parent 551c3eb commit 4f455f4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/test/test_io/test_textio.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
import weakref
1212
from collections import UserList
1313
from test import support
14-
from test.support import os_helper, threading_helper
14+
from test.support import (
15+
os_helper,
16+
set_recursion_limit,
17+
threading_helper
18+
)
1519
from test.support.script_helper import assert_python_ok
1620
from .utils import CTestCase, PyTestCase
1721

@@ -1591,12 +1595,12 @@ def write(self, b):
15911595
('reconfigure', lambda: wrapper.reconfigure(line_buffering=True)),
15921596
]
15931597
for name, method in tests:
1594-
with self.subTest(name):
1598+
with self.subTest(name), set_recursion_limit(100):
15951599
wrapper = self.TextIOWrapper(EvilBuffer(self.MockRawIO()), encoding='utf-8')
15961600
wrapper_ref = weakref.ref(wrapper)
15971601
# These used to crash; now either return detached or keep
15981602
# running until out of stack.
1599-
self.assertRaisesRegex(RuntimeError, "detached|recursion depth exceeded", method)
1603+
self.assertRaises((RecursionError, RuntimeError), method)
16001604
wrapper_ref = None
16011605
del wrapper
16021606

0 commit comments

Comments
 (0)