Commits

Armin Rigo committed d7a56e5

Test and fix

Comments (0)

Files changed (2)

pypy/module/_cffi_backend/func.py

 def sizeof(space, w_obj):
     ob = space.interpclass_w(w_obj)
     if isinstance(ob, cdataobj.W_CData):
-        # xxx CT_ARRAY
-        size = ob.ctype.size
+        if isinstance(ob, cdataobj.W_CDataNewOwningLength):
+            size = ob._owning_num_bytes()
+        else:
+            size = ob.ctype.size
     elif isinstance(ob, ctypeobj.W_CType):
         size = ob.size
         if size < 0:

pypy/module/_cffi_backend/test/_backend_test_c.py

     BArray = new_array_type(new_pointer_type(BInt), None)   # int[]
     p = newp(BArray, 7)
     assert repr(p) == "<cdata 'int[]' owning 28 bytes>"
+    assert sizeof(p) == 28