We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PyErr::new
Continuing from #4400, where we observed that a tuple was being flattened as part of a call to PyErr::new.
The other special case is that PyErr::new(py.None()) counts as no arguments.
PyErr::new(py.None())
#[pyo3::pymodule] mod pyo3_scratch { use pyo3::prelude::*; #[pyfunction] fn bug(py: Python<'_>) -> PyResult<()> { Err(pyo3::exceptions::PyValueError::new_err(py.None())) } }
>>> try: ... pyo3_scratch.bug() ... except ValueError as e: ... print(e.args) ... ()
Again if we wrap the py.None() in a tuple as (py.None(),) then the final e.args will be (None,).
py.None()
(py.None(),)
e.args
(None,)
I'm open to debating whether we should change PyErr::new, because this doesn't match Python users' instincts, where there is no special case:
>>> print(ValueError(None).args) (None,) >>> print(ValueError((1,)).args) ((1,),)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Continuing from #4400, where we observed that a tuple was being flattened as part of a call to
PyErr::new
.The other special case is that
PyErr::new(py.None())
counts as no arguments.Again if we wrap the
py.None()
in a tuple as(py.None(),)
then the finale.args
will be(None,)
.I'm open to debating whether we should change
PyErr::new
, because this doesn't match Python users' instincts, where there is no special case:The text was updated successfully, but these errors were encountered: