Skip to content

Commit 15f1299

Browse files
committed
convert tuple iteration to use Py2 in list
1 parent b1ece19 commit 15f1299

File tree

4 files changed

+123
-103
lines changed

4 files changed

+123
-103
lines changed

Cargo.lock

Lines changed: 69 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input/input_python.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl<'a> Input<'a> for PyAny {
566566
fn extract_generic_iterable(&'a self) -> ValResult<GenericIterable<'a>> {
567567
// Handle concrete non-overlapping types first, then abstract types
568568
if let Ok(iterable) = self.downcast::<PyList>() {
569-
Ok(GenericIterable::List(iterable))
569+
Ok(GenericIterable::List(Py2::borrowed_from_gil_ref(&iterable).clone()))
570570
} else if let Ok(iterable) = self.downcast::<PyTuple>() {
571571
Ok(GenericIterable::Tuple(iterable))
572572
} else if let Ok(iterable) = self.downcast::<PySet>() {
@@ -746,6 +746,13 @@ impl BorrowInput for &'_ PyAny {
746746
}
747747
}
748748

749+
impl BorrowInput for Py2<'_, PyAny> {
750+
type Input<'a> = PyAny where Self: 'a;
751+
fn borrow_input(&self) -> &Self::Input<'_> {
752+
self.as_gil_ref()
753+
}
754+
}
755+
749756
/// Best effort check of whether it's likely to make sense to inspect obj for attributes and iterate over it
750757
/// with `obj.dir()`
751758
fn from_attributes_applicable(obj: &PyAny) -> bool {

0 commit comments

Comments
 (0)