Skip to content

Commit

Permalink
Merge pull request #942 from davidhewitt/iterator-comment
Browse files Browse the repository at this point in the history
Improve comment in iterator.rs
  • Loading branch information
kngwyu authored May 21, 2020
2 parents 7fd35b2 + 01a74b2 commit 89fe62e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/types/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ impl<'p> PyIterator<'p> {
}

if ffi::PyIter_Check(ptr) != 0 {
// this is not right, but this cause of segfault check #71
// This looks suspicious, but is actually correct. Even though ptr is an owned
// reference, PyIterator takes ownership of the reference and decreases the count
// in its Drop implementation.
//
// Therefore we must use from_borrowed_ptr instead of from_owned_ptr so that the
// GILPool does not take ownership of the reference.
Ok(PyIterator(py.from_borrowed_ptr(ptr)))
} else {
Err(PyDowncastError)
Expand Down

0 comments on commit 89fe62e

Please sign in to comment.