Author: Andrew Leech <and...@alelec.net>
Branch: new_struct_allocated_size
Changeset: r2788:9d05a8fc0297
Date: 2016-09-12 15:10 +1000
http://bitbucket.org/cffi/cffi/changeset/9d05a8fc0297/

Log:    When getting repr on CDataObject_own_structptr, use length field for
        owned bytes

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -1814,7 +1814,9 @@
 static PyObject *cdataowning_repr(CDataObject *cd)
 {
     Py_ssize_t size;
-    if (cd->c_type->ct_flags & CT_POINTER)
+    if (cd->c_type->ct_flags & CT_IS_PTR_TO_OWNED)
+        size = ((CDataObject_own_structptr *)cd)->length;
+    else if (cd->c_type->ct_flags & CT_POINTER)
         size = cd->c_type->ct_itemdescr->ct_size;
     else if (cd->c_type->ct_flags & CT_ARRAY)
         size = get_array_length(cd) * cd->c_type->ct_itemdescr->ct_size;
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to