From fc5620afa68a802b5953c2ef05b74611a908a054 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Sun, 24 Jul 2016 17:34:53 +0100 Subject: [PATCH] Fix a segfault where func object wasn't released --- include/pybind11/numpy.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 3b52fa39b..3956c34c1 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -150,9 +150,10 @@ public: } private: - static object& _dtype_from_pep3118() { - static object obj = module::import("numpy.core._internal").attr("_dtype_from_pep3118"); - return obj; + static object _dtype_from_pep3118() { + static PyObject *obj = module::import("numpy.core._internal") + .attr("_dtype_from_pep3118").cast().release().ptr(); + return object(obj, true); } dtype strip_padding() {