fix declarative-modules compile error (#4054)

* fix declarative-modules compile error

* add newsfragment
This commit is contained in:
Icxolu 2024-04-12 08:34:27 +02:00 committed by David Hewitt
parent fd18955da8
commit e501377587
3 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1 @@
Fixes a compile error when exporting a `#[pyclass]` living in a different Rust module using the declarative-module feature.

View File

@ -1614,7 +1614,7 @@ impl<'a> PyClassImplsBuilder<'a> {
quote! {
impl #cls {
#[doc(hidden)]
const _PYO3_DEF: #pyo3_path::impl_::pymodule::AddClassToModule<Self> = #pyo3_path::impl_::pymodule::AddClassToModule::new();
pub const _PYO3_DEF: #pyo3_path::impl_::pymodule::AddClassToModule<Self> = #pyo3_path::impl_::pymodule::AddClassToModule::new();
}
}
}

View File

@ -9,6 +9,13 @@ use pyo3::types::PyBool;
#[path = "../src/tests/common.rs"]
mod common;
mod some_module {
use pyo3::prelude::*;
#[pyclass]
pub struct SomePyClass;
}
#[pyclass]
struct ValueClass {
value: usize,
@ -50,6 +57,10 @@ mod declarative_module {
#[pymodule_export]
use super::{declarative_module2, double, MyError, ValueClass as Value};
// test for #4036
#[pymodule_export]
use super::some_module::SomePyClass;
#[pymodule]
mod inner {
use super::*;