-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92b0f15
commit 3670c42
Showing
8 changed files
with
19 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix compile failure in declarative `#[pymodule]` under presence of `#![no_implicit_prelude]`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
#![no_implicit_prelude] | ||
#![allow(unused_variables, clippy::unnecessary_wraps)] | ||
|
||
#[crate::pyfunction] | ||
#[pyo3(crate = "crate")] | ||
fn do_something(x: i32) -> crate::PyResult<i32> { | ||
::std::result::Result::Ok(x) | ||
} | ||
|
||
#[test] | ||
#[cfg(feature = "gil-refs")] | ||
fn invoke_wrap_pyfunction() { | ||
crate::Python::with_gil(|py| { | ||
#[allow(deprecated)] | ||
let func = crate::wrap_pyfunction!(do_something)(py).unwrap(); | ||
crate::py_run!(py, func, r#"func(5)"#); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn invoke_wrap_pyfunction_bound() { | ||
crate::Python::with_gil(|py| { | ||
let func = crate::wrap_pyfunction_bound!(do_something, py).unwrap(); | ||
let func = crate::wrap_pyfunction!(do_something, py).unwrap(); | ||
crate::py_run!(py, func, r#"func(5)"#); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,36 @@ | ||
#![no_implicit_prelude] | ||
#![allow(unused_variables, clippy::unnecessary_wraps)] | ||
|
||
#[crate::pyfunction] | ||
#[pyo3(crate = "crate")] | ||
fn do_something(x: i32) -> crate::PyResult<i32> { | ||
::std::result::Result::Ok(x) | ||
} | ||
|
||
#[cfg(feature = "gil-refs")] | ||
#[allow(deprecated)] | ||
#[crate::pymodule] | ||
#[pyo3(crate = "crate")] | ||
fn foo(_py: crate::Python<'_>, _m: &crate::types::PyModule) -> crate::PyResult<()> { | ||
::std::result::Result::Ok(()) | ||
} | ||
|
||
#[crate::pymodule] | ||
#[pyo3(crate = "crate")] | ||
fn foo_bound( | ||
fn foo( | ||
_py: crate::Python<'_>, | ||
_m: &crate::Bound<'_, crate::types::PyModule>, | ||
) -> crate::PyResult<()> { | ||
::std::result::Result::Ok(()) | ||
} | ||
|
||
#[cfg(feature = "gil-refs")] | ||
#[allow(deprecated)] | ||
#[crate::pymodule] | ||
#[pyo3(crate = "crate")] | ||
fn my_module(_py: crate::Python<'_>, m: &crate::types::PyModule) -> crate::PyResult<()> { | ||
m.add_function(crate::wrap_pyfunction!(do_something, m)?)?; | ||
m.add_wrapped(crate::wrap_pymodule!(foo))?; | ||
|
||
::std::result::Result::Ok(()) | ||
} | ||
|
||
#[crate::pymodule] | ||
#[pyo3(crate = "crate")] | ||
fn my_module_bound(m: &crate::Bound<'_, crate::types::PyModule>) -> crate::PyResult<()> { | ||
fn my_module(m: &crate::Bound<'_, crate::types::PyModule>) -> crate::PyResult<()> { | ||
<crate::Bound<'_, crate::types::PyModule> as crate::types::PyModuleMethods>::add_function( | ||
m, | ||
crate::wrap_pyfunction_bound!(do_something, m)?, | ||
)?; | ||
<crate::Bound<'_, crate::types::PyModule> as crate::types::PyModuleMethods>::add_wrapped( | ||
m, | ||
crate::wrap_pymodule!(foo_bound), | ||
crate::wrap_pymodule!(foo), | ||
)?; | ||
|
||
::std::result::Result::Ok(()) | ||
} | ||
|
||
#[crate::pymodule(submodule)] | ||
#[pyo3(crate = "crate")] | ||
mod my_module_declarative { | ||
#[pymodule_export] | ||
use super::{do_something, foo}; | ||
} |