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

benjamin at codespeak.net benjamin at codespeak.net
Wed Jan 20 03:25:18 CET 2010


Author: benjamin
Date: Wed Jan 20 03:25:16 2010
New Revision: 70719

Modified:
   pypy/trunk/pypy/objspace/std/objspace.py
   pypy/trunk/pypy/objspace/std/test/test_userobject.py
Log:
fix descriptor handling with getattributeshortcut enabled

Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/pypy/objspace/std/objspace.py	Wed Jan 20 03:25:16 2010
@@ -654,15 +654,15 @@
                 w_value = w_obj.getdictvalue_attr_is_in_class(self, name)
                 if w_value is not None:
                     return w_value
-            try:
-                return self.get(w_descr, w_obj)
-            except OperationError, e:
-                if not e.match(self, self.w_AttributeError):
-                    raise
-        else:
-            w_value = w_obj.getdictvalue(self, name)
-            if w_value is not None:
-                return w_value
+            w_get = self.lookup(w_descr, "__get__")
+            if w_get is not None:
+                return self.get_and_call_function(w_get, w_descr, w_obj, w_type)
+        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/std/test/test_userobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_userobject.py	(original)
+++ pypy/trunk/pypy/objspace/std/test/test_userobject.py	Wed Jan 20 03:25:16 2010
@@ -1,5 +1,6 @@
 import py
 from pypy.interpreter import gateway
+from pypy.objspace.test import test_descriptor
 
 
 class AppTestUserObject:
@@ -294,6 +295,19 @@
         multimethod.Installer = cls.prev_installer
 
 
-class AppTestWithGetAttributeShortcut(AppTestUserObject):
-    OPTIONS = {"objspace.std.getattributeshortcut": True}
+class GetAttributeShortcutTest:
 
+    def setup_class(cls):
+        from pypy import conftest
+        options = {"objspace.std.getattributeshortcut" : True}
+        cls.space = conftest.gettestobjspace(**options)
+
+
+class AppTestWithGetAttributeShortcut(AppTestUserObject,
+                                      GetAttributeShortcutTest):
+    pass
+
+
+class AppTestDescriptorWithGetAttributeShortcut(
+    test_descriptor.AppTest_Descriptor, GetAttributeShortcutTest):
+    pass



More information about the Pypy-commit mailing list