From 4a34cc63a67d14397b30d5cc064742a0848a556d Mon Sep 17 00:00:00 2001 From: Mo Mirza Date: Sun, 26 Sep 2021 09:01:23 +0100 Subject: [PATCH] Remove use of unwrap (#1888) * Remove use of unwrap * Update changelog * Update CHANGELOG.md Co-authored-by: Mo Mirza Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com> --- CHANGELOG.md | 1 + pyo3-macros-backend/src/from_pyobject.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ece689e..da4a31d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix building with a conda environment on Windows. [#1873](https://github.com/PyO3/pyo3/pull/1873) - Fix panic on Python 3.6 when calling `Python::with_gil` with Python initialized but threading not initialized. [#1874](https://github.com/PyO3/pyo3/pull/1874) - Fix incorrect linking to version-specific DLL instead of `python3.dll` when cross-compiling to Windows with `abi3`. [#1880](https://github.com/PyO3/pyo3/pull/1880) +- Fix panic in generated `#[derive(FromPyObject)]` for enums. [#1888](https://github.com/PyO3/pyo3/pull/1888) ## [0.14.5] - 2021-09-05 diff --git a/pyo3-macros-backend/src/from_pyobject.rs b/pyo3-macros-backend/src/from_pyobject.rs index 79015b0c..2afec0df 100644 --- a/pyo3-macros-backend/src/from_pyobject.rs +++ b/pyo3-macros-backend/src/from_pyobject.rs @@ -63,7 +63,7 @@ impl<'a> Enum<'a> { ok @ ::std::result::Result::Ok(_) => return ok, ::std::result::Result::Err(inner) => { let py = ::pyo3::PyNativeType::py(obj); - err_reasons.push_str(&::std::format!("{}\n", inner.instance(py).str().unwrap())); + err_reasons.push_str(&::std::format!("{}\n", inner.instance(py).str()?)); } } );