Skip to content

Commit 18f84e1

Browse files
committed
fix either feature conditional compilation, again
1 parent e308c8d commit 18f84e1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

newsfragments/3834.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix compilation failure with `either` feature enabled without `experimental-inspect` enabled.

src/conversions/either.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ where
9494
} else if let Ok(r) = obj.extract::<R>() {
9595
Ok(Either::Right(r))
9696
} else {
97-
let err_msg = format!("failed to convert the value to '{}'", Self::type_input());
97+
// TODO: it might be nice to use the `type_input()` name here once `type_input`
98+
// is not experimental, rather than the Rust type names.
99+
let err_msg = format!(
100+
"failed to convert the value to 'Union[{}, {}]'",
101+
std::any::type_name::<L>(),
102+
std::any::type_name::<R>()
103+
);
98104
Err(PyTypeError::new_err(err_msg))
99105
}
100106
}
@@ -134,7 +140,7 @@ mod tests {
134140
assert!(err.is_instance_of::<PyTypeError>(py));
135141
assert_eq!(
136142
err.to_string(),
137-
"TypeError: failed to convert the value to 'Union[int, float]'"
143+
"TypeError: failed to convert the value to 'Union[i32, f32]'"
138144
);
139145

140146
let obj_i = 42.to_object(py);

0 commit comments

Comments
 (0)