Remove __doc__ from module's __all__

This commit is contained in:
messense 2021-03-20 11:16:52 +08:00
parent 20452a7c09
commit acd4601d2f
3 changed files with 11 additions and 1 deletions

View File

@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `PyTypeObject_INIT` [#1429](https://github.com/PyO3/pyo3/pull/1429)
- `PyObject_Check`, `PySuper_Check`, and `FreeFunc` [#1438](https://github.com/PyO3/pyo3/pull/1438)
- Remove pyclass implementation details `Type`, `DESCRIPTION`, and `FLAGS` from `PyTypeInfo`. [#1456](https://github.com/PyO3/pyo3/pull/1456)
- Remove `__doc__` from module's `__all__`. [#1509](https://github.com/PyO3/pyo3/pull/1509)
### Fixed
- Remove FFI definition `PyCFunction_ClearFreeList` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)

View File

@ -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))
}

View File

@ -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()