Commits

Andrews Medina committed ab9512f

fixed support for class in stdlib 2.7.4

  • Participants
  • Parent commits de804d0
  • Branches stdlib-2.7.4-fixed-class

Comments (0)

Files changed (2)

File pypy/module/__builtin__/interp_classobj.py

         return None
 
     def descr_getattribute(self, space, w_attr):
+        if not space.isinstance_w(w_attr, space.w_str):
+            msg = "attribute name must be a string"
+            raise OperationError(space.w_TypeError, space.wrap(msg))
         name = unwrap_attr(space, w_attr)
         if name and name[0] == "_":
             if name == "__dict__":
         return space.call_function(w_descr_get, w_value, space.w_None, self)
 
     def descr_setattr(self, space, w_attr, w_value):
+        if not space.isinstance_w(w_attr, space.w_str):
+            msg = "attribute name must be a string"
+            raise OperationError(space.w_TypeError, space.wrap(msg))
         name = unwrap_attr(space, w_attr)
         if name and name[0] == "_":
             if name == "__dict__":
             return None
 
     def descr_getattribute(self, space, w_attr):
+        if not space.isinstance_w(w_attr, space.w_str):
+            msg = "attribute name must be a string"
+            raise OperationError(space.w_TypeError, space.wrap(msg))
         name = space.str_w(w_attr)
         if len(name) >= 8 and name[0] == '_':
             if name == "__dict__":
         return self.getattr(space, name)
 
     def descr_setattr(self, space, w_name, w_value):
+        if not space.isinstance_w(w_name, space.w_str):
+            msg = "attribute name must be a string"
+            raise OperationError(space.w_TypeError, space.wrap(msg))
         name = unwrap_attr(space, w_name)
         w_meth = self.getattr_from_class(space, '__setattr__')
         if name and name[0] == "_":

File pypy/module/__builtin__/test/test_classobj.py

             b = 2
         assert self.is_strdict(A)
 
+    def test_attr_slots(self):
+        class C:
+            pass
+        for c in C, C():
+            raises(TypeError, type(c).__getattribute__, c, [])
+            raises(TypeError, type(c).__setattr__, c, [], [])
+
 class AppTestOldStyleMapDict(AppTestOldstyle):
     spaceconfig = {"objspace.std.withmapdict": True}