[pypy-commit] pypy default: Support buffers instead of only strings here

arigo noreply at buildbot.pypy.org
Mon Jan 20 15:48:31 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r68785:da89455f80b5
Date: 2014-01-20 15:47 +0100
http://bitbucket.org/pypy/pypy/changeset/da89455f80b5/

Log:	Support buffers instead of only strings here

diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -579,7 +579,7 @@
     s = rffi.wcharpsize2unicode(rffi.cast(rffi.CWCHARP, address), maxlength)
     return space.wrap(s)
 
- at unwrap_spec(address=r_uint, newcontent=str)
+ at unwrap_spec(address=r_uint, newcontent='bufferstr')
 def rawstring2charp(space, address, newcontent):
     from rpython.rtyper.annlowlevel import llstr
     from rpython.rtyper.lltypesystem.rstr import copy_string_to_raw
diff --git a/pypy/module/_rawffi/test/test__rawffi.py b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -330,6 +330,8 @@
         a = A(10, 'x'*10)
         _rawffi.rawstring2charp(a.buffer, "foobar")
         assert ''.join([a[i] for i in range(10)]) == "foobarxxxx"
+        _rawffi.rawstring2charp(a.buffer, buffer("baz"))
+        assert ''.join([a[i] for i in range(10)]) == "bazbarxxxx"
         a.free()
 
     def test_raw_callable(self):


More information about the pypy-commit mailing list