Commits

Armin Rigo committed d03f7f2

Update to cffi/65a3bcbcb054

Comments (0)

Files changed (2)

pypy/module/_cffi_backend/cbuffer.py

     def descr__buffer__(self, space):
         return self.buffer.descr__buffer__(space)
 
+    def descr_str(self, space):
+        return space.wrap(self.buffer.as_str())
+
+    def descr_unicode(self, space):
+        return space.repr(space.wrap(self))
+
 
 MiniBuffer.typedef = TypeDef(
     "buffer",
     __setitem__ = interp2app(MiniBuffer.descr_setitem),
     __buffer__ = interp2app(MiniBuffer.descr__buffer__),
     __weakref__ = make_weakref_descr(MiniBuffer),
+    __str__ = interp2app(MiniBuffer.descr_str),
+    __unicode__ = interp2app(MiniBuffer.descr_unicode),
     )
 MiniBuffer.typedef.acceptable_as_base_class = False
 

pypy/module/_cffi_backend/test/_backend_test_c.py

     c = newp(BCharArray, b"hi there")
     #
     buf = buffer(c)
-    assert str(buf).startswith('<_cffi_backend.buffer object at 0x')
+    assert unicode(buf).startswith('<_cffi_backend.buffer object at 0x')
+    assert bytes(buf) == b"hi there\x00"
     # --mb_length--
     assert len(buf) == len(b"hi there\x00")
     # --mb_item--