Merge pull request #942 from davidhewitt/iterator-comment

Improve comment in iterator.rs
This commit is contained in:
Yuji Kanagawa 2020-05-21 16:21:01 +09:00 committed by GitHub
commit 89fe62eb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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)