Author: Armin Rigo <ar...@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) -@unwrap_spec(address=r_uint, newcontent=str) +@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): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit