Use err::cast_from_owned_ptr_or_panic, because PyDict_Items creates a new reference to list and can fail.

This commit is contained in:
Dmitry Trofimov 2015-07-09 00:51:12 +02:00
parent 79abfb99e8
commit d495eaaa4a
1 changed files with 1 additions and 2 deletions

View File

@ -108,8 +108,7 @@ impl <'p> PyDict<'p> {
pub fn items(&self) -> PyList {
let py = self.python();
unsafe {
let pyobj = PyObject::from_borrowed_ptr(py, ffi::PyDict_Items(self.as_ptr()));
pyobj.unchecked_cast_into::<PyList>()
err::cast_from_owned_ptr_or_panic(py, ffi::PyDict_Items(self.as_ptr()))
}
}
}