[pypy-commit] pypy default: Issue #2039

arigo noreply at buildbot.pypy.org
Tue May 5 14:51:26 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r77146:2d1cc91dc7d9
Date: 2015-05-05 14:51 +0200
http://bitbucket.org/pypy/pypy/changeset/2d1cc91dc7d9/

Log:	Issue #2039

	Test and fix: TypeError -> AttributeError

diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -181,14 +181,14 @@
     def set(space, w_descr, w_obj, w_val):
         w_set = space.lookup(w_descr, '__set__')
         if w_set is None:
-            raise oefmt(space.w_TypeError,
+            raise oefmt(space.w_AttributeError,
                         "'%T' object is not a descriptor with set", w_descr)
         return space.get_and_call_function(w_set, w_descr, w_obj, w_val)
 
     def delete(space, w_descr, w_obj):
         w_delete = space.lookup(w_descr, '__delete__')
         if w_delete is None:
-            raise oefmt(space.w_TypeError,
+            raise oefmt(space.w_AttributeError,
                         "'%T' object is not a descriptor with delete", w_descr)
         return space.get_and_call_function(w_delete, w_descr, w_obj)
 
diff --git a/pypy/objspace/test/test_descroperation.py b/pypy/objspace/test/test_descroperation.py
--- a/pypy/objspace/test/test_descroperation.py
+++ b/pypy/objspace/test/test_descroperation.py
@@ -783,3 +783,19 @@
         assert [2] + A1([3]) == [2, 3]
         assert type([2] + A1([3])) is list
         assert [2] + A2([3]) == 42
+
+    def test_data_descriptor_without_delete(self):
+        class D(object):
+            def __set__(self, x, y):
+                pass
+        class A(object):
+            d = D()
+        raises(AttributeError, "del A().d")
+
+    def test_data_descriptor_without_set(self):
+        class D(object):
+            def __delete__(self, x):
+                pass
+        class A(object):
+            d = D()
+        raises(AttributeError, "A().d = 5")


More information about the pypy-commit mailing list