@@ -2,7 +2,7 @@ use super::PyMapping;
2
2
use crate :: err:: { self , PyErr , PyResult } ;
3
3
use crate :: ffi:: Py_ssize_t ;
4
4
use crate :: ffi_ptr_ext:: FfiPtrExt ;
5
- use crate :: instance:: Py2 ;
5
+ use crate :: instance:: { Py2 , Py2Borrowed } ;
6
6
use crate :: py_result_ext:: PyResultExt ;
7
7
use crate :: types:: any:: PyAnyMethods ;
8
8
use crate :: types:: { PyAny , PyList } ;
@@ -406,7 +406,7 @@ impl<'py> PyDictMethods<'py> for Py2<'py, PyDict> {
406
406
match unsafe {
407
407
ffi:: PyDict_GetItemWithError ( dict. as_ptr ( ) , key. as_ptr ( ) )
408
408
. assume_borrowed_or_opt ( py)
409
- . map ( |borrowed_any| borrowed_any . clone ( ) )
409
+ . map ( Py2Borrowed :: to_owned )
410
410
} {
411
411
some @ Some ( _) => Ok ( some) ,
412
412
None => PyErr :: take ( py) . map ( Err ) . transpose ( ) ,
@@ -595,8 +595,8 @@ impl<'py> Iterator for PyDictIterator2<'py> {
595
595
// - PyDict_Next returns borrowed values
596
596
// - we have already checked that `PyDict_Next` succeeded, so we can assume these to be non-null
597
597
Some ( (
598
- unsafe { key. assume_borrowed_unchecked ( py) } . clone ( ) ,
599
- unsafe { value. assume_borrowed_unchecked ( py) } . clone ( ) ,
598
+ unsafe { key. assume_borrowed_unchecked ( py) } . to_owned ( ) ,
599
+ unsafe { value. assume_borrowed_unchecked ( py) } . to_owned ( ) ,
600
600
) )
601
601
} else {
602
602
None
0 commit comments