Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: py3.7
Changeset: r98673:a75c90ba20f9
Date: 2020-02-05 13:33 +0100
http://bitbucket.org/pypy/pypy/changeset/a75c90ba20f9/

Log:    sys.setrecursionlimit changes:
        - change error message in one case
        - skip a test: extremely low recursionlimits just lead to very strange
        behavior
        - change the skip reason of another test: there's no need to "fix"
        this, PyPy behaves more correctly here

diff --git a/lib-python/3/test/test_sys.py b/lib-python/3/test/test_sys.py
--- a/lib-python/3/test/test_sys.py
+++ b/lib-python/3/test/test_sys.py
@@ -193,6 +193,7 @@
         self.assertEqual(sys.getrecursionlimit(), 10000)
         sys.setrecursionlimit(oldlimit)
 
+    @test.support.cpython_only
     def test_recursionlimit_recovery(self):
         if hasattr(sys, 'gettrace') and sys.gettrace():
             self.skipTest('fatal error if run with a trace function')
@@ -251,7 +252,7 @@
         finally:
             sys.setrecursionlimit(oldlimit)
 
-    @unittest.skipIf(True, 'Fixme: hangs with pypy')
+    @unittest.skipIf(True, 'pypy supports this just fine')
     def test_recursionlimit_fatalerror(self):
         # A fatal error occurs if a second recursion limit is hit when 
recovering
         # from a first one.
diff --git a/pypy/module/sys/test/test_sysmodule.py 
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -524,6 +524,16 @@
         sys.setrecursionlimit(oldlimit)
         raises(OverflowError, sys.setrecursionlimit, 1<<31)
 
+    def test_recursionlimit_toolow(self):
+        import sys
+        def callatlevel(l):
+            if l > 0:
+                callatlevel(l - 1)
+            else:
+                sys.setrecursionlimit(1)
+        with raises(RecursionError):
+            callatlevel(500)
+
     def test_getwindowsversion(self):
         import sys
         if hasattr(sys, "getwindowsversion"):
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -79,7 +79,7 @@
         old_limit = space.sys.recursionlimit
         _stack_set_length_fraction(old_limit * 0.001)
         raise oefmt(space.w_RecursionError,
-                    "maximum recursion depth exceeded")
+                "cannot set the recursion limit to %s at the recursion depth: 
the limit is too low")
     space.sys.recursionlimit = new_limit
     increase_root_stack_depth(int(new_limit * 0.001 * 163840))
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to