Author: Manuel Jacob
Branch: remove-set-smm
Changeset: r64144:47becb14728e
Date: 2013-05-15 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/47becb14728e/

Log:    Add type checks in operator implementations.

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -261,32 +261,48 @@
             raise
 
     def descr_sub(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         return self.difference(w_other)
 
     def descr_and(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         return self.intersect(w_other)
 
     def descr_or(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         w_copy = self.copy_real()
         w_copy.update(w_other)
         return w_copy
 
     def descr_xor(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         return self.symmetric_difference(w_other)
 
     def descr_inplace_sub(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         self.difference_update(w_other)
         return self
 
     def descr_inplace_and(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         self.intersect_update(w_other)
         return self
 
     def descr_inplace_or(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         self.update(w_other)
         return self
 
     def descr_inplace_xor(self, space, w_other):
+        if not isinstance(w_other, W_BaseSetObject):
+            return space.w_NotImplemented
         self.descr_symmetric_difference_update(space, w_other)
         return self
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to