fix: do not set docstring for function when empty (#2745)

* Do not set docstring for function when it's empty

* No need to check pointer for `free`

* Use ternary operator to conditionally set `ml_doc`
This commit is contained in:
Qifan Lu
2020-12-27 19:56:30 -08:00
committed by GitHub
parent 830f8eda87
commit d587a2fd17
3 changed files with 14 additions and 3 deletions

View File

@@ -45,6 +45,14 @@ TEST_SUBMODULE(docstring_options, m) {
m.def("test_function7", [](int, int) {}, py::arg("a"), py::arg("b"), "A custom docstring");
{
py::options options;
options.disable_user_defined_docstrings();
options.disable_function_signatures();
m.def("test_function8", []() {});
}
{
py::options options;
options.disable_user_defined_docstrings();