[pypy-commit] cffi default: Test and fix.
arigo
noreply at buildbot.pypy.org
Fri Jun 15 20:57:14 CEST 2012
Author: Armin Rigo <arigo at 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):
More information about the pypy-commit
mailing list