Release source when PyIterReturn::StopIteration
@@ -96,10 +96,13 @@ mod decl {
}
}
};
- next.map_err(|err| {
+ match next {
+ Err(_) | Ok(PyIterReturn::StopIteration(_)) => {
*zelf.source.write() = None;
- err
- })
+ }
+ _ => {}
+ };
+ next
}
}
