fix declarative module compile error with `create_exception!` (#4086)
* fix declarative module compile error with `create_exception!` * add newsfragment
This commit is contained in:
parent
2ad2a3f208
commit
03f59eaf45
|
@ -0,0 +1 @@
|
|||
Fixes a compile error when exporting an exception created with `create_exception!` living in a different Rust module using the `declarative-module` feature.
|
|
@ -252,7 +252,7 @@ macro_rules! pyobject_native_type_info(
|
|||
|
||||
impl $name {
|
||||
#[doc(hidden)]
|
||||
const _PYO3_DEF: $crate::impl_::pymodule::AddTypeToModule<Self> = $crate::impl_::pymodule::AddTypeToModule::new();
|
||||
pub const _PYO3_DEF: $crate::impl_::pymodule::AddTypeToModule<Self> = $crate::impl_::pymodule::AddTypeToModule::new();
|
||||
}
|
||||
};
|
||||
);
|
||||
|
|
|
@ -10,10 +10,14 @@ use pyo3::types::PyBool;
|
|||
mod common;
|
||||
|
||||
mod some_module {
|
||||
use pyo3::create_exception;
|
||||
use pyo3::exceptions::PyException;
|
||||
use pyo3::prelude::*;
|
||||
|
||||
#[pyclass]
|
||||
pub struct SomePyClass;
|
||||
|
||||
create_exception!(some_module, SomeException, PyException);
|
||||
}
|
||||
|
||||
#[pyclass]
|
||||
|
@ -61,6 +65,10 @@ mod declarative_module {
|
|||
#[pymodule_export]
|
||||
use super::some_module::SomePyClass;
|
||||
|
||||
// test for #4036
|
||||
#[pymodule_export]
|
||||
use super::some_module::SomeException;
|
||||
|
||||
#[pymodule]
|
||||
mod inner {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in New Issue