Skip to content

Commit

Permalink
Remove __doc__ from module's __all__
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Mar 20, 2021
1 parent 20452a7 commit 518ada3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/derive_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl ModuleDef {
return Err(crate::PyErr::fetch(py));
}
let module = py.from_owned_ptr_or_err::<PyModule>(module)?;
module.add("__doc__", doc)?;
module.setattr("__doc__", doc)?;
initializer(py, module)?;
Ok(crate::IntoPyPointer::into_ptr(module))
}
Expand Down
9 changes: 9 additions & 0 deletions tests/test_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ fn test_module_dict() {
py_assert!(py, module, "module.yay == 'me'");
}

#[test]
fn test_module_dunder_all() {
let gil = Python::acquire_gil();
let py = gil.python();
let module = pyo3::wrap_pymodule!(foobar_module)(py);

py_assert!(py, module, "module.__all__ == ['foobar']");
}

#[pyfunction]
fn subfunction() -> String {
"Subfunction".to_string()
Expand Down

0 comments on commit 518ada3

Please sign in to comment.