[pypy-svn] r73181 - in pypy/trunk/pypy: interpreter rlib rlib/test rpython

arigo at codespeak.net arigo at codespeak.net
Tue Mar 30 17:59:58 CEST 2010


Author: arigo
Date: Tue Mar 30 17:59:56 2010
New Revision: 73181

Modified:
   pypy/trunk/pypy/interpreter/gateway.py
   pypy/trunk/pypy/interpreter/pyopcode.py
   pypy/trunk/pypy/rlib/rstackovf.py
   pypy/trunk/pypy/rlib/test/test_rstackovf.py
   pypy/trunk/pypy/rpython/llinterp.py
Log:
I know this trickery with AttributeError is for
module/__builtin__/test/test_builtin, however I could not reproduce the
original failure, and it seems like a *very* bad idea to catch random
AttributeErrors and report them as "RuntimeError: maximum recursion
depth exceeded" on top of py.py or in tests.  I suppose that we might
fix test_builtin directly if the problem shows up again.

Also, remove the argument to check_stack_overflow().


Modified: pypy/trunk/pypy/interpreter/gateway.py
==============================================================================
--- pypy/trunk/pypy/interpreter/gateway.py	(original)
+++ pypy/trunk/pypy/interpreter/gateway.py	Tue Mar 30 17:59:56 2010
@@ -574,7 +574,7 @@
         except MemoryError: 
             raise OperationError(space.w_MemoryError, space.w_None)
         except rstackovf.StackOverflow, e:
-            rstackovf.check_stack_overflow(e)
+            rstackovf.check_stack_overflow()
             raise OperationError(space.w_RuntimeError,
                                 space.wrap("maximum recursion depth exceeded"))
 

Modified: pypy/trunk/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyopcode.py	(original)
+++ pypy/trunk/pypy/interpreter/pyopcode.py	Tue Mar 30 17:59:56 2010
@@ -109,7 +109,7 @@
                 self.space.w_MemoryError)
         except rstackovf.StackOverflow, e:
             # Note that this case catches AttributeError!
-            rstackovf.check_stack_overflow(e)
+            rstackovf.check_stack_overflow()
             next_instr = self.handle_asynchronous_error(ec,
                 self.space.w_RuntimeError,
                 self.space.wrap("maximum recursion depth exceeded"))

Modified: pypy/trunk/pypy/rlib/rstackovf.py
==============================================================================
--- pypy/trunk/pypy/rlib/rstackovf.py	(original)
+++ pypy/trunk/pypy/rlib/rstackovf.py	Tue Mar 30 17:59:56 2010
@@ -1,3 +1,4 @@
+import sys
 from pypy.rlib.objectmodel import we_are_translated
 
 # RPython raises StackOverflow instead of just RuntimeError when running
@@ -13,14 +14,14 @@
 _StackOverflow = StackOverflow
 
 # replace StackOverflow with this, which works in untranslated code too
-StackOverflow = ((RuntimeError, AttributeError),)
+StackOverflow = ((RuntimeError, RuntimeError),)
 
 
-def check_stack_overflow(e):
+def check_stack_overflow():
     if we_are_translated():
         return
     # before translation, an "except StackOverflow" includes all RuntimeErrors,
     # including NotImplementedError.  Special-case them.
-    if ((type(e) is not RuntimeError or 'recursion' not in str(e))
-        and type(e) is not AttributeError):
-        raise e
+    e, v, _ = sys.exc_info()
+    if e is not RuntimeError or 'recursion' not in str(v):
+        raise

Modified: pypy/trunk/pypy/rlib/test/test_rstackovf.py
==============================================================================
--- pypy/trunk/pypy/rlib/test/test_rstackovf.py	(original)
+++ pypy/trunk/pypy/rlib/test/test_rstackovf.py	Tue Mar 30 17:59:56 2010
@@ -25,6 +25,7 @@
         return getattr(self, attr)
 
 def test_raises_AttributeError():
+    py.test.skip("not RPython code...")
     rga = RecurseGetAttr()
     try:
         rga.y

Modified: pypy/trunk/pypy/rpython/llinterp.py
==============================================================================
--- pypy/trunk/pypy/rpython/llinterp.py	(original)
+++ pypy/trunk/pypy/rpython/llinterp.py	Tue Mar 30 17:59:56 2010
@@ -323,7 +323,7 @@
             if not (catch_exception and op is block.operations[-1]):
                 raise
         except RuntimeError, e:
-            rstackovf.check_stack_overflow(e)
+            rstackovf.check_stack_overflow()
             # xxx fish fish fish for proper etype and evalue to use
             rtyper = self.llinterpreter.typer
             bk = rtyper.annotator.bookkeeper



More information about the Pypy-commit mailing list