[pypy-svn] r49756 - in pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Fri Dec 14 01:34:51 CET 2007


Author: cfbolz
Date: Fri Dec 14 01:34:50 2007
New Revision: 49756

Modified:
   pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
   pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
Log:
test and fix for a problem that CPython's test_class revealed


Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py	(original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py	Fri Dec 14 01:34:50 2007
@@ -319,7 +319,13 @@
         w_descr_get = space.lookup(w_value, '__get__')
         if w_descr_get is None:
             return w_value
-        return space.call_function(w_descr_get, w_value, self, self.w_class)
+        try:
+            return space.call_function(w_descr_get, w_value, self, self.w_class)
+        except OperationError, e:
+            if exc or not e.match(space, space.w_AttributeError):
+                raise
+            return None
+
 
     def descr_getattribute(self, space, w_attr):
         #import pdb; pdb.set_trace()

Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py	(original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py	Fri Dec 14 01:34:50 2007
@@ -598,3 +598,13 @@
         gc.collect()
         gc.collect()
         assert l == [1, 1]
+
+    def test_catch_attributeerror_of_descriptor(self):
+        def booh(self):
+            raise AttributeError, "booh"
+
+        class E:
+            __eq__ = property(booh)
+
+        # does not crash
+        E() == E()



More information about the Pypy-commit mailing list