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

fix declarative module compile error with create_exception! #4086

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4086.fixed.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
);
Expand Down
8 changes: 8 additions & 0 deletions tests/test_declarative_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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::*;
Expand Down
Loading