Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative modules don't set item's module properly #4070

Open
wyfo opened this issue Apr 12, 2024 · 1 comment
Open

Declarative modules don't set item's module properly #4070

wyfo opened this issue Apr 12, 2024 · 1 comment

Comments

@wyfo
Copy link
Contributor

wyfo commented Apr 12, 2024

Using this code

use pyo3::prelude::*;

#[pymodule]
mod my_extension {
    #[pymodule]
    mod submodule {
        #[pyfunction]
        fn foo() {}
    }
}

my_extension.submodule.foo.__module__ returns submodule instead of my_extension.submodule, as it would be expected for pure Python modules.

Relates to #3900

@davidhewitt
Copy link
Member

davidhewitt commented Apr 13, 2024

Agreed this could be much better. There's additional runtime complexity because my_extension might itself be a submodule to a pure python root e.g. my_package.my_native_code_extension.submodule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants