diff --git a/src/impl_/frompyobject.rs b/src/impl_/frompyobject.rs index 29706a78ed4..a0c7b13df7c 100644 --- a/src/impl_/frompyobject.rs +++ b/src/impl_/frompyobject.rs @@ -16,11 +16,9 @@ pub fn failed_to_extract_enum( ); for ((variant_name, error_name), error) in variant_names.iter().zip(error_names).zip(errors) { use std::fmt::Write; - - err_msg.push('\n'); write!( &mut err_msg, - "- variant {variant_name} ({error_name}): {error_msg}", + "\n- variant {variant_name} ({error_name}): {error_msg}", variant_name = variant_name, error_name = error_name, error_msg = extract_traceback(py, error.clone_ref(py)), @@ -36,7 +34,7 @@ fn extract_traceback(py: Python<'_>, mut error: PyErr) -> String { let mut error_msg = error.to_string(); while let Some(cause) = error.cause(py) { - write!(&mut error_msg, ", caused by {}", cause).unwrap(); + write!(&mut error_msg, ", caused by {}", cause).unwrap(); error = cause } error_msg diff --git a/tests/test_compile_error.rs b/tests/test_compile_error.rs index 8933bca30d5..7ce3300a5a2 100644 --- a/tests/test_compile_error.rs +++ b/tests/test_compile_error.rs @@ -109,6 +109,9 @@ fn _test_compile_errors() { t.compile_fail("tests/ui/invalid_pymethod_receiver.rs"); t.compile_fail("tests/ui/invalid_result_conversion.rs"); t.compile_fail("tests/ui/missing_intopy.rs"); + + // Only run this with these features to avoid different outputs + #[cfg(all(feature = "full", not(feature = "abi3")))] t.compile_fail("tests/ui/missing_clone.rs"); } diff --git a/tests/ui/abi3_nativetype_inheritance.stderr b/tests/ui/abi3_nativetype_inheritance.stderr index 25084a3c969..2ac0dce88a6 100644 --- a/tests/ui/abi3_nativetype_inheritance.stderr +++ b/tests/ui/abi3_nativetype_inheritance.stderr @@ -4,6 +4,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied 5 | #[pyclass(extends=PyDict)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict` | + = help: the trait `PyClass` is implemented for `TestClass` = note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict` = note: this error originates in the attribute macro `pyclass` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -13,6 +14,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied 5 | #[pyclass(extends=PyDict)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict` | + = help: the trait `PyClass` is implemented for `TestClass` = note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict` note: required by a bound in `PyRefMut` --> src/pycell.rs @@ -27,6 +29,7 @@ error[E0277]: the trait bound `PyDict: PyClass` is not satisfied 5 | #[pyclass(extends=PyDict)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `PyClass` is not implemented for `PyDict` | + = help: the trait `PyClass` is implemented for `TestClass` = note: required because of the requirements on the impl of `PyClassBaseType` for `PyDict` note: required by a bound in `ThreadCheckerInherited` --> src/impl_/pyclass.rs