-
Notifications
You must be signed in to change notification settings - Fork 803
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
Comments
Agreed this could be much better. There's additional runtime complexity because |
I have opened #4213 that should fix it |
Closing as resolved in #4213 |
Sorry to post on an older issue but this seems like it's related, if I should open a new issue let me know and I'll go ahead and do that. If you define a function on a submodule then the This also behaves differently with a class. Just as a very simple example if you defined a module like this: #[pymodule]
mod my_module {
use super::*;
#[pyfunction]
fn double(x: i64) -> PyResult<i64> {
Ok(x * 2)
}
#[pyclass]
struct DummyClassRootMod {}
#[pymodule]
mod dummy_submodule {
use super::*;
#[pyfunction]
fn triple(x: i64) -> PyResult<i64> {
Ok(x * 3)
}
#[pyclass]
struct DummyClassSubMod {}
}
} If I then use this in Python I can see the module defined correctly on the top level function, but the submodules are not defined the way I'd expect. Additionally it seems like the classes aren't defined quite right, I'm using maturin with my project and have my module-name defined as from project import my_module
my_module.double.__module__
Out[3]: 'project.my_module'
my_module.dummy_submodule.triple.__module__
Out[4]: 'dummy_submodule'
my_module.DummyClassRootMod.__module__
Out[5]: 'my_module'
my_module.dummy_submodule.DummyClassSubMod.__module__
Out[6]: 'my_module.dummy_submodule' |
Hi @b-kiiskila, I think it would be best to open a new issue - it's easier to keep track of open problems if they're in open issues. |
Using this code
my_extension.submodule.foo.__module__
returnssubmodule
instead ofmy_extension.submodule
, as it would be expected for pure Python modules.Relates to #3900
The text was updated successfully, but these errors were encountered: