[pypy-commit] pypy py3.5-memoryview: readded missing hex method to bytes. seemed it got lost during a merge

plan_rich pypy.commits at gmail.com
Mon Aug 29 08:07:06 EDT 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5-memoryview
Changeset: r86691:715ec3109ab7
Date: 2016-08-29 14:06 +0200
http://bitbucket.org/pypy/pypy/changeset/715ec3109ab7/

Log:	readded missing hex method to bytes. seemed it got lost during a
	merge

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
@@ -659,6 +659,10 @@
     def descr_upper(self, space):
         return W_BytesObject(self._value.upper())
 
+    def descr_hex(self, space):
+        from pypy.objspace.std.bytearrayobject import _array_to_hexstring
+        return _array_to_hexstring(space, StringBuffer(self._value))
+
 
 def _create_list_from_bytes(value):
     # need this helper function to allow the jit to look inside and inline
@@ -838,6 +842,7 @@
 
     fromhex = interp2app(W_BytesObject.descr_fromhex, as_classmethod=True),
     maketrans = interp2app(W_BytesObject.descr_maketrans, as_classmethod=True),
+    hex = interp2app(W_BytesObject.descr_hex),
 )
 W_BytesObject.typedef.flag_sequence_bug_compat = True
 
diff --git a/pypy/objspace/std/test/test_memoryobject.py b/pypy/objspace/std/test/test_memoryobject.py
--- a/pypy/objspace/std/test/test_memoryobject.py
+++ b/pypy/objspace/std/test/test_memoryobject.py
@@ -210,21 +210,6 @@
                 self.data.append(c)
         self.data = ''.join(self.data)
 
-    def getslice(self, start, stop, step, size):
-        items = []
-        if size == 0:
-            return ''
-        return ''.join([self.getitem(i) for i in range(start,stop,step)])
-        #bytecount = (stop - start)
-        ## data is stores as list of ints, thus this gets around the
-        ## issue that one cannot advance in bytes
-        #count = bytecount // size
-        #start = start // size
-        #for i in range(start, start+count, step):
-        #    items.append(self.getitem(i))
-        #return ''.join(items)
-
-
     def getformat(self):
         return self.format
 


More information about the pypy-commit mailing list