From ba0732e7dc7b171970f5dddf29ecbdbcde29a171 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 17 Jan 2016 22:36:42 +0100 Subject: [PATCH] fixed a terrible bug in def_property_static and switched to the faster PyObject_CallFunctionObjArgs API call --- include/pybind11/pybind11.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 9749147f8..df43217ae 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -975,9 +975,9 @@ public: class_ &def_property(const char *name, const cpp_function &fget, const cpp_function &fset, const char *doc = nullptr) { object doc_obj = doc ? pybind11::str(doc) : (object) const_cast(fget).attr("__doc__"); object property( - PyObject_CallFunction((PyObject *)&PyProperty_Type, - const_cast("OOOO"), fget.ptr() ? fget.ptr() : Py_None, - fset.ptr() ? fset.ptr() : Py_None, Py_None, doc_obj.ptr()), false); + PyObject_CallFunctionObjArgs((PyObject *) &PyProperty_Type, + fget.ptr() ? fget.ptr() : Py_None, + fset.ptr() ? fset.ptr() : Py_None, Py_None, doc_obj.ptr(), nullptr), false); attr(name) = property; return *this; } @@ -985,9 +985,9 @@ public: class_ &def_property_static(const char *name, const cpp_function &fget, const cpp_function &fset, const char *doc = nullptr) { object doc_obj = doc ? pybind11::str(doc) : (object) const_cast(fget).attr("__doc__"); object property( - PyObject_CallFunction((PyObject *)&PyProperty_Type, - const_cast("OOOs"), fget.ptr() ? fget.ptr() : Py_None, - fset.ptr() ? fset.ptr() : Py_None, Py_None, doc_obj.ptr()), false); + PyObject_CallFunctionObjArgs((PyObject *) &PyProperty_Type, + fget.ptr() ? fget.ptr() : Py_None, + fset.ptr() ? fset.ptr() : Py_None, Py_None, doc_obj.ptr(), nullptr), false); metaclass().attr(name) = property; return *this; }