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

Cannot give Option function argument a default value but still pass None explicitly #932

Closed
birkenfeld opened this issue May 17, 2020 · 1 comment · Fixed by #936
Closed
Labels

Comments

@birkenfeld
Copy link
Member

Using 0.10. Extension module code:

use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

#[pymodule]
fn test(_py: Python, m: &PyModule) -> PyResult<()> {
    m.add_wrapped(wrap_pyfunction!(testfn))
}

#[pyfunction(arg="true")]
fn testfn(arg: Option<bool>) {
    println!("{:?}", arg);
}

Test in interpreter:

>>> import test
>>> test.testfn()
Some(true)
>>> test.testfn(True)
Some(true)
>>> test.testfn(False)
Some(false)
>>> test.testfn(None)
Some(true)

There is no way to make the argument None anymore...

@davidhewitt
Copy link
Member

Thanks, see #936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants