Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r66272:94ba4b49ed07
Date: 2013-08-21 03:08 +0200
http://bitbucket.org/pypy/pypy/changeset/94ba4b49ed07/

Log:    Override rich comparison implementations in W_BytesObject. They
        return w_NotImplemented when comparing with objects that aren't
        instances of W_BytesObject.

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -565,6 +565,36 @@
     def descr_buffer(self, space):
         return space.wrap(StringBuffer(self._value))
 
+    def descr_eq(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value == w_other._value)
+
+    def descr_ne(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value != w_other._value)
+
+    def descr_lt(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value < w_other._value)
+
+    def descr_le(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value <= w_other._value)
+
+    def descr_gt(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value > w_other._value)
+
+    def descr_ge(self, space, w_other):
+        if not isinstance(w_other, W_BytesObject):
+            return space.w_NotImplemented
+        return space.newbool(self._value >= w_other._value)
+
     # auto-conversion fun
 
     _StringMethods_descr_add = descr_add
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to