diff --git a/CHANGELOG.md b/CHANGELOG.md index b1fd8677..428243f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/derive_utils.rs b/src/derive_utils.rs index 390807d2..f24e93cc 100644 --- a/src/derive_utils.rs +++ b/src/derive_utils.rs @@ -320,7 +320,7 @@ impl ModuleDef { return Err(crate::PyErr::fetch(py)); } let module = py.from_owned_ptr_or_err::(module)?; - module.add("__doc__", doc)?; + module.setattr("__doc__", doc)?; initializer(py, module)?; Ok(crate::IntoPyPointer::into_ptr(module)) } diff --git a/tests/test_module.rs b/tests/test_module.rs index 7262a872..303306c1 100644 --- a/tests/test_module.rs +++ b/tests/test_module.rs @@ -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()