mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
fixed a terrible bug in def_property_static and switched to the faster PyObject_CallFunctionObjArgs API call
This commit is contained in:
parent
678d787ca4
commit
ba0732e7dc
@ -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<cpp_function&>(fget).attr("__doc__");
|
||||
object property(
|
||||
PyObject_CallFunction((PyObject *)&PyProperty_Type,
|
||||
const_cast<char *>("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<cpp_function&>(fget).attr("__doc__");
|
||||
object property(
|
||||
PyObject_CallFunction((PyObject *)&PyProperty_Type,
|
||||
const_cast<char *>("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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user