Commits

Simon Cross committed 55e0a79

Remove bytearray.{strip,lstrip,rstrip} multimethods (fijal, hodgestar).

Comments (0)

Files changed (2)

pypy/objspace/std/bytearrayobject.py

     def descr_reverse(self, space):
         self.data.reverse()
 
+    def descr_strip(self, space, w_chars=None):
+        if space.is_none(w_chars):
+            chars = _space_chars
+        else:
+            chars = space.bufferstr_new_w(w_chars)
+        return _strip(space, self, chars, 1, 1)
+
+    def descr_lstrip(self, space, w_chars=None):
+        if space.is_none(w_chars):
+            chars = _space_chars
+        else:
+            chars = space.bufferstr_new_w(w_chars)
+        return _strip(space, self, chars, 1, 0)
+
+    def descr_rstrip(self, space, w_chars=None):
+        if space.is_none(w_chars):
+            chars = _space_chars
+        else:
+            chars = space.bufferstr_new_w(w_chars)
+        return _strip(space, self, chars, 0, 1)
+
     def __repr__(w_self):
         """ representation for debugging purposes """
         return "%s(%s)" % (w_self.__class__.__name__, ''.join(w_self.data))
 
 _space_chars = ''.join([chr(c) for c in [9, 10, 11, 12, 13, 32]])
 
-def bytearray_strip__Bytearray_None(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, _space_chars, 1, 1)
-
-def bytearray_strip__Bytearray_ANY(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 1, 1)
-
-def bytearray_lstrip__Bytearray_None(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, _space_chars, 1, 0)
-
-def bytearray_lstrip__Bytearray_ANY(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 1, 0)
-
-def bytearray_rstrip__Bytearray_None(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, _space_chars, 0, 1)
-
-def bytearray_rstrip__Bytearray_ANY(space, w_bytearray, w_chars):
-    return _strip(space, w_bytearray, space.bufferstr_new_w(w_chars), 0, 1)
 
 # These methods could just delegate to the string implementation,
 # but they have to return a bytearray.

pypy/objspace/std/bytearraytype.py

         """
         raise NotImplementedError
 
+    def descr_strip(self, space, w_chars=None):
+        """B.strip([bytes]) -> bytearray
 
-bytearray_strip  = SMM('strip', 2, defaults=(None,),
-                    doc="B.strip([bytes]) -> bytearray\n\nStrip leading "
-                    "and trailing bytes contained in the argument.\nIf "
-                    "the argument is omitted, strip ASCII whitespace.")
+        Strip leading and trailing bytes contained in the argument.
+        If the argument is omitted, strip ASCII whitespace.
+        """
+        raise NotImplementedError
 
-bytearray_lstrip  = SMM('lstrip', 2, defaults=(None,),
-                    doc="B.lstrip([bytes]) -> bytearray\n\nStrip leading "
-                    "bytes contained in the argument.\nIf the argument is "
-                    "omitted, strip leading ASCII whitespace.")
+    def descr_lstrip(self, space, w_chars=None):
+        """B.lstrip([bytes]) -> bytearray
 
-bytearray_rstrip  = SMM('rstrip', 2, defaults=(None,),
-                    doc="'B.rstrip([bytes]) -> bytearray\n\nStrip trailing "
-                    "bytes contained in the argument.\nIf the argument is "
-                    "omitted, strip trailing ASCII whitespace.")
+        Strip leading bytes contained in the argument.
+        If the argument is omitted, strip leading ASCII whitespace.
+        """
+        raise NotImplementedError
+
+    def descr_rstrip(self, space, w_chars=None):
+        """B.rstrip([bytes]) -> bytearray
+
+        Strip trailing bytes contained in the argument.
+        If the argument is omitted, strip trailing ASCII whitespace.
+        """
+        raise NotImplementedError
+
 
 def getbytevalue(space, w_value):
     if space.isinstance_w(w_value, space.w_str):
     extend=interpindirect2app(W_AbstractBytearrayObject.descr_extend),
     join=interpindirect2app(W_AbstractBytearrayObject.descr_join),
     reverse=interpindirect2app(W_AbstractBytearrayObject.descr_reverse),
+    strip=interpindirect2app(W_AbstractBytearrayObject.descr_strip),
+    lstrip=interpindirect2app(W_AbstractBytearrayObject.descr_lstrip),
+    rstrip=interpindirect2app(W_AbstractBytearrayObject.descr_rstrip),
     )
 bytearray_typedef.registermethods(globals())