[pypy-svn] r60984 - in pypy/trunk/pypy: module/__builtin__ objspace/std/test

fijal at codespeak.net fijal at codespeak.net
Thu Jan 15 00:17:35 CET 2009


Author: fijal
Date: Thu Jan 15 00:17:35 2009
New Revision: 60984

Modified:
   pypy/trunk/pypy/module/__builtin__/interp_classobj.py
   pypy/trunk/pypy/objspace/std/test/test_userobject.py
Log:
a fix for deleting attribute of instances of oldstyle classes


Modified: pypy/trunk/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/interp_classobj.py	(original)
+++ pypy/trunk/pypy/module/__builtin__/interp_classobj.py	Thu Jan 15 00:17:35 2009
@@ -400,7 +400,11 @@
         if w_meth is not None:
             space.call_function(w_meth, w_name)
         else:
-            self.deldictvalue(space, w_name)
+            if not self.deldictvalue(space, w_name):
+                raise OperationError(
+                    space.w_AttributeError,
+                    space.wrap("%s instance has no attribute %s" % (
+                        self.w_class.name, space.str_w(space.str(w_name)))))
 
     def descr_repr(self, space):
         w_meth = self.getattr(space, space.wrap('__repr__'), False)

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	Thu Jan 15 00:17:35 2009
@@ -208,7 +208,6 @@
         assert s.startswith('<a.b.c.Foo object at ')
 
     def test_del_attr(self):
-        skip("Fails")
         class Foo(object):
             def __init__(self):
                 self.x = 3
@@ -237,6 +236,17 @@
         else:
             raise Exception("DID NOT RAISE")
 
+    def test_del_attr_class(self):
+        class Foo:
+            pass
+
+        try:
+            del Foo.x
+        except AttributeError:
+            pass
+        else:
+            raise Exception("DID NOT RAISE")
+
 class AppTestWithMultiMethodVersion2(AppTestUserObject):
     OPTIONS = {}    # for test_builtinshortcut.py
 



More information about the Pypy-commit mailing list