[3.9] bpo-45806: Fix recovery from stack overflow for 3.9. Again. by markshannon · Pull Request #29640 · python/cpython

Expand Up @@ -260,42 +260,10 @@ def set_recursion_limit_at_depth(depth, limit): sys.setrecursionlimit(1000)
for limit in (10, 25, 50, 75, 100, 150, 200): # formula extracted from _Py_RecursionLimitLowerWaterMark() if limit > 200: depth = limit - 50 else: depth = limit * 3 // 4 set_recursion_limit_at_depth(depth, limit) set_recursion_limit_at_depth(limit, limit) finally: sys.setrecursionlimit(oldlimit)
# The error message is specific to CPython @test.support.cpython_only def test_recursionlimit_fatalerror(self): # A fatal error occurs if a second recursion limit is hit when recovering # from a first one. code = textwrap.dedent(""" import sys
def f(): try: f() except RecursionError: f()
sys.setrecursionlimit(%d) f()""") with test.support.SuppressCrashReport(): for i in (50, 1000): sub = subprocess.Popen([sys.executable, '-c', code % i], stderr=subprocess.PIPE) err = sub.communicate()[1] self.assertTrue(sub.returncode, sub.returncode) self.assertIn( b"Fatal Python error: _Py_CheckRecursiveCall: " b"Cannot recover from stack overflow", err)
def test_getwindowsversion(self): # Raise SkipTest if sys doesn't have getwindowsversion attribute test.support.get_attribute(sys, "getwindowsversion") Expand Down