Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r86279:044728302224
Date: 2016-08-18 17:03 +0200
http://bitbucket.org/pypy/pypy/changeset/044728302224/

Log:    Add the new RecursionError exception.

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1936,6 +1936,7 @@
     'PendingDeprecationWarning',
     'ReferenceError',
     'ResourceWarning',
+    'RecursionError',
     'RuntimeError',
     'RuntimeWarning',
     'StopIteration',
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -720,7 +720,7 @@
             raise OperationError(space.w_MemoryError, space.w_None)
         except rstackovf.StackOverflow as e:
             rstackovf.check_stack_overflow()
-            raise oefmt(space.w_RuntimeError,
+            raise oefmt(space.w_RecursionError,
                         "maximum recursion depth exceeded")
         except RuntimeError:   # not on top of py.py
             raise OperationError(space.w_RuntimeError, space.w_None)
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -96,7 +96,7 @@
             # Note that this case catches AttributeError!
             rstackovf.check_stack_overflow()
             next_instr = self.handle_asynchronous_error(ec,
-                self.space.w_RuntimeError,
+                self.space.w_RecursionError,
                 self.space.wrap("maximum recursion depth exceeded"))
         return next_instr
 
diff --git a/pypy/interpreter/test/test_interpreter.py 
b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -407,7 +407,7 @@
         def f(): f()
         try:
             f()
-        except RuntimeError as e:
+        except RecursionError as e:
             assert str(e) == "maximum recursion depth exceeded"
         else:
             assert 0, "should have raised!"
diff --git a/pypy/module/exceptions/__init__.py 
b/pypy/module/exceptions/__init__.py
--- a/pypy/module/exceptions/__init__.py
+++ b/pypy/module/exceptions/__init__.py
@@ -47,6 +47,7 @@
         'PendingDeprecationWarning' : 
'interp_exceptions.W_PendingDeprecationWarning',
         'PermissionError': 'interp_exceptions.W_PermissionError',
         'ProcessLookupError': 'interp_exceptions.W_ProcessLookupError',
+        'RecursionError' : 'interp_exceptions.W_RecursionError',
         'ReferenceError' : 'interp_exceptions.W_ReferenceError',
         'ResourceWarning'  : 'interp_exceptions.W_ResourceWarning',
         'RuntimeError' : 'interp_exceptions.W_RuntimeError',
diff --git a/pypy/module/exceptions/interp_exceptions.py 
b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -64,6 +64,7 @@
       +-- ReferenceError
       +-- RuntimeError
       |    +-- NotImplementedError
+      |    +-- RecursionError
       +-- SyntaxError
       |    +-- IndentationError
       |         +-- TabError
@@ -921,6 +922,9 @@
 W_NotImplementedError = _new_exception('NotImplementedError', W_RuntimeError,
                         """Method or function hasn't been implemented yet.""")
 
+W_RecursionError = _new_exception('RecursionError', W_RuntimeError,
+                        """Recursion limit exceeded.""")
+
 W_AttributeError = _new_exception('AttributeError', W_Exception,
                                   """Attribute not found.""")
 
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
@@ -44,8 +44,8 @@
 @unwrap_spec(new_limit="c_int")
 def setrecursionlimit(space, new_limit):
     """setrecursionlimit() sets the maximum number of nested calls that
-can occur before a RuntimeError is raised.  On PyPy the limit is
-approximative and checked at a lower level.  The default 1000
+can occur before a RecursionError is raised.  On PyPy the limit
+is approximative and checked at a lower level.  The default 1000
 reserves 768KB of stack space, which should suffice (on Linux,
 depending on the compiler settings) for ~1400 calls.  Setting the
 value to N reserves N/1000 times 768KB of stack space.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to