diff --git a/src/class/methods.rs b/src/class/methods.rs index ea2c2c34..362f78bc 100644 --- a/src/class/methods.rs +++ b/src/class/methods.rs @@ -97,6 +97,9 @@ impl PyGetterDef { .expect("Method name must not contain NULL byte") .into_raw(); } + if dst.doc.is_null() { + dst.doc = self.doc.as_ptr() as *mut libc::c_char; + } dst.get = Some(self.meth); } } diff --git a/tests/test_getter_setter.rs b/tests/test_getter_setter.rs index 7eede5be..ee5057af 100644 --- a/tests/test_getter_setter.rs +++ b/tests/test_getter_setter.rs @@ -1,4 +1,5 @@ use pyo3::prelude::*; +use pyo3::types::IntoPyDict; use std::isize; #[macro_use] @@ -16,6 +17,7 @@ impl ClassWithProperties { } #[getter(DATA)] + /// a getter for data fn get_data(&self) -> PyResult { Ok(self.num) } @@ -38,6 +40,9 @@ fn class_with_properties() { py_run!(py, inst, "inst.DATA = 20"); py_run!(py, inst, "assert inst.get_num() == 20"); py_run!(py, inst, "assert inst.get_num() == inst.DATA"); + + let d = [("C", py.get_type::())].into_py_dict(py); + py.run("assert C.DATA.__doc__ == 'a getter for data'", None, Some(d)).unwrap(); } #[pyclass]