Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r377:d55cf06971e3 Date: 2012-06-15 20:57 +0200 http://bitbucket.org/cffi/cffi/changeset/d55cf06971e3/
Log: Test and fix. diff --git a/c/_ffi_backend.c b/c/_ffi_backend.c --- a/c/_ffi_backend.c +++ b/c/_ffi_backend.c @@ -3119,7 +3119,7 @@ return NULL; if (cd->c_type->ct_flags & CT_POINTER) - length = cd->c_type->ct_size; + length = cd->c_type->ct_itemdescr->ct_size; else if (cd->c_type->ct_flags & CT_ARRAY) length = get_array_length(cd) * cd->c_type->ct_itemdescr->ct_size; else { diff --git a/testing/backend_tests.py b/testing/backend_tests.py --- a/testing/backend_tests.py +++ b/testing/backend_tests.py @@ -759,15 +759,16 @@ def test_ffi_buffer_ptr(self): ffi = FFI(backend=self.Backend()) - a = ffi.new("int", 100) + a = ffi.new("short", 100) b = ffi.buffer(a) assert type(b) is buffer + assert len(str(b)) == 2 if sys.byteorder == 'little': - assert str(b) == '\x64\x00\x00\x00' + assert str(b) == '\x64\x00' b[0] = '\x65' else: - assert str(b) == '\x00\x00\x00\x64' - b[3] = '\x65' + assert str(b) == '\x00\x64' + b[1] = '\x65' assert a[0] == 101 def test_ffi_buffer_array(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit