From 13022f1b8cf533711994b505858025fcd3ea345c Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Sun, 3 Jul 2016 10:22:40 +0100 Subject: [PATCH] Bugfix: pass struct size as itemsize to descriptor Without this, partially bound structs will have incorrect itemsize. --- include/pybind11/numpy.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 1046cd43..423403dd 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -266,6 +266,7 @@ struct npy_format_descriptor::value> args["names"] = names; args["offsets"] = offsets; args["formats"] = formats; + args["itemsize"] = int_(sizeof(T)); // This is essentially the same as calling np.dtype() constructor in Python and passing // it a dict of the form {'names': ..., 'formats': ..., 'offsets': ...}. if (!api.PyArray_DescrConverter_(args.release().ptr(), &dtype_()) || !dtype_())