[pypy-commit] pypy default: Update to cffi/65a3bcbcb054

arigo noreply at buildbot.pypy.org
Fri Dec 6 21:28:16 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r68388:d03f7f2b76da
Date: 2013-12-06 19:57 +0100
http://bitbucket.org/pypy/pypy/changeset/d03f7f2b76da/

Log:	Update to cffi/65a3bcbcb054

diff --git a/pypy/module/_cffi_backend/cbuffer.py b/pypy/module/_cffi_backend/cbuffer.py
--- a/pypy/module/_cffi_backend/cbuffer.py
+++ b/pypy/module/_cffi_backend/cbuffer.py
@@ -59,6 +59,12 @@
     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",
@@ -68,6 +74,8 @@
     __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
 
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -2143,7 +2143,8 @@
     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--


More information about the pypy-commit mailing list