array: fix sequence lengths in error message

This commit is contained in:
David Hewitt 2021-04-27 23:53:56 +01:00 committed by GitHub
parent 068e3117a5
commit a084cd5a2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -177,9 +177,9 @@ where
T: FromPyObject<'s>,
{
let seq = <crate::types::PySequence as PyTryFrom>::try_from(obj)?;
let expected_len = seq.len()? as usize;
if expected_len != slice.len() {
return Err(invalid_sequence_length(expected_len, slice.len()));
let seq_len = seq.len()? as usize;
if seq_len != slice.len() {
return Err(invalid_sequence_length(slice.len(), seq_len));
}
for (value, item) in slice.iter_mut().zip(seq.iter()?) {
*value = item?.extract::<T>()?;