From d71d4329ae07efd1080b578f3522105d011ec26f Mon Sep 17 00:00:00 2001 From: R2D2 Date: Thu, 27 May 2021 22:36:19 +0200 Subject: [PATCH] Changed format of TypeError messages --- pyo3-macros-backend/src/from_pyobject.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyo3-macros-backend/src/from_pyobject.rs b/pyo3-macros-backend/src/from_pyobject.rs index 79e2d4b9..89ce719d 100644 --- a/pyo3-macros-backend/src/from_pyobject.rs +++ b/pyo3-macros-backend/src/from_pyobject.rs @@ -245,17 +245,17 @@ impl<'a> Container<'a> { let get_field = quote!(obj.#getter?); let extractor = match &attrs.from_py_with { None => quote!(#get_field.extract().map_err(|inner| { - let err_msg = format!("Failed to extract field {} of {}:\n{} ", - stringify!(#ident), + let err_msg = format!("failed to extract field {}.{}\n\nCaused by:\n {}\n", stringify!(#self_ty), + stringify!(#ident), inner); pyo3::exceptions::PyTypeError::new_err(err_msg) })?), Some(FromPyWithAttribute(expr_path)) => quote! (#expr_path(#get_field). map_err(|inner| { - let err_msg = format!("Failed to extract field {} of {}:\n{} ", - stringify!(#ident), + let err_msg = format!("failed to extract field {}.{}\n\nCaused by:\n {}\n", stringify!(#self_ty), + stringify!(#ident), inner); pyo3::exceptions::PyTypeError::new_err(err_msg) })?),