[pypy-commit] pypy default: test, fix corner case in the fix to #3149 that broke lib-python test

mattip pypy.commits at gmail.com
Sun Jan 19 21:44:54 EST 2020


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r98560:dc4c8f284eee
Date: 2020-01-20 13:44 +1100
http://bitbucket.org/pypy/pypy/changeset/dc4c8f284eee/

Log:	test, fix corner case in the fix to #3149 that broke lib-python test

diff --git a/pypy/module/__builtin__/abstractinst.py b/pypy/module/__builtin__/abstractinst.py
--- a/pypy/module/__builtin__/abstractinst.py
+++ b/pypy/module/__builtin__/abstractinst.py
@@ -232,7 +232,10 @@
     # many-years issue report: https://bugs.python.org/issue12029), and
     # there are probably tests, so we won't call abstract_issubclass_w()
     # either in PyPy3.
-    return abstract_issubclass_w(space, w_cls1, w_cls2, True)
+    try:
+        return abstract_issubclass_w(space, w_cls1, w_cls2, True)
+    except OperationError as e:
+        return False
 
 # ____________________________________________________________
 # App-level interface
diff --git a/pypy/module/__builtin__/test/test_abstractinst.py b/pypy/module/__builtin__/test/test_abstractinst.py
--- a/pypy/module/__builtin__/test/test_abstractinst.py
+++ b/pypy/module/__builtin__/test/test_abstractinst.py
@@ -259,3 +259,35 @@
             raise Special, ValueError()
         except ValueError:
             pass
+
+    def test_exception_bad_subclasscheck(self):
+        import sys
+        class Meta(type):
+            def __subclasscheck__(cls, subclass):
+                raise ValueError()
+
+        class MyException(Exception):
+            __metaclass__ = Meta
+            pass
+
+        try:
+            raise KeyError()
+        except MyException, e:
+            assert False, "exception should not be a MyException"
+        except KeyError:
+            pass
+        except:
+            assert False, "Should have raised KeyError"
+        else:
+            assert False, "Should have raised KeyError"
+
+        def g():
+            try:
+                return g()
+            except RuntimeError:
+                return sys.exc_info()
+        e, v, tb = g()
+        assert e is RuntimeError, str(e)
+        assert "maximum recursion depth exceeded" in str(v)
+
+ 


More information about the pypy-commit mailing list