[pypy-svn] r70811 - in pypy/trunk/pypy/objspace: std test

benjamin at codespeak.net benjamin at codespeak.net
Sun Jan 24 20:32:30 CET 2010


Author: benjamin
Date: Sun Jan 24 20:32:29 2010
New Revision: 70811

Modified:
   pypy/trunk/pypy/objspace/std/objspace.py
   pypy/trunk/pypy/objspace/test/test_descriptor.py
Log:
don't search in the obj dict or return the descr if __get__ raises an AttributeError

Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/pypy/objspace/std/objspace.py	Sun Jan 24 20:32:29 2010
@@ -664,12 +664,13 @@
                 except OperationError, e:
                     if not e.match(self, self.w_AttributeError):
                         raise
-        w_value = w_obj.getdictvalue(self, name)
-        if w_value is not None:
-            return w_value
-        # No value in __dict__. Fallback to the descriptor if we have it.
-        if w_descr is not None:
-            return w_descr
+        if e is None:
+            w_value = w_obj.getdictvalue(self, name)
+            if w_value is not None:
+                return w_value
+            # No value in __dict__. Fallback to the descriptor if we have it.
+            if w_descr is not None:
+                return w_descr
 
         w_descr = self.lookup(w_obj, '__getattr__')
         if w_descr is not None:

Modified: pypy/trunk/pypy/objspace/test/test_descriptor.py
==============================================================================
--- pypy/trunk/pypy/objspace/test/test_descriptor.py	(original)
+++ pypy/trunk/pypy/objspace/test/test_descriptor.py	Sun Jan 24 20:32:29 2010
@@ -49,6 +49,7 @@
                 if name == 'v':
                     return 42
         x = X()
+        print(x.v)
         assert x.v == 42
 
         # ... but the __dict__ is not searched



More information about the Pypy-commit mailing list