@@ -11,7 +11,6 @@ use crate::{
1111 } ,
1212 class:: { PyClassDef , PyClassImpl } ,
1313 common:: ascii,
14- convert:: ToPyObject ,
1514 dictdatatype:: { self , DictKey } ,
1615 function:: {
1716 ArgIterable , FuncArgs , KwArgs , OptionalArg , PyArithmeticValue :: * , PyComparisonValue ,
@@ -24,7 +23,8 @@ use crate::{
2423 IterNextIterable , Iterable , PyComparisonOp , Unconstructible , Unhashable ,
2524 } ,
2625 vm:: VirtualMachine ,
27- AsObject , Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult , TryFromObject ,
26+ AsObject , Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyRefExact , PyResult ,
27+ TryFromObject ,
2828} ;
2929use once_cell:: sync:: Lazy ;
3030use rustpython_common:: lock:: PyMutex ;
@@ -65,8 +65,9 @@ impl PyDict {
6565
6666 // Used in update and ior.
6767 pub ( crate ) fn merge_object ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
68- let other = match other. downcast_exact ( vm) {
69- Ok ( dict_other) => return self . merge_dict ( dict_other, vm) ,
68+ let casted: Result < PyRefExact < PyDict > , _ > = other. downcast_exact ( vm) ;
69+ let other = match casted {
70+ Ok ( dict_other) => return self . merge_dict ( dict_other. into_pyref ( ) , vm) ,
7071 Err ( other) => other,
7172 } ;
7273 let dict = & self . entries ;
@@ -227,7 +228,7 @@ impl PyDict {
227228 for key in iterable. iter ( vm) ? {
228229 pydict. setitem ( key?, value. clone ( ) , vm) ?;
229230 }
230- Ok ( pydict. to_pyobject ( vm ) )
231+ Ok ( pydict. into_pyref ( ) . into ( ) )
231232 }
232233 Err ( pyobj) => {
233234 for key in iterable. iter ( vm) ? {
0 commit comments