@@ -6,7 +6,7 @@ use super::objstr;
6
6
use super :: objtype:: { self , PyClassRef } ;
7
7
use crate :: dictdatatype:: { self , DictKey } ;
8
8
use crate :: exceptions:: PyBaseExceptionRef ;
9
- use crate :: function:: { KwArgs , OptionalArg } ;
9
+ use crate :: function:: { KwArgs , OptionalArg , PyFuncArgs } ;
10
10
use crate :: pyobject:: {
11
11
IdProtocol , IntoPyObject , ItemProtocol , PyAttributes , PyClassImpl , PyContext , PyIterable ,
12
12
PyObjectRef , PyRef , PyResult , PyValue ,
@@ -41,20 +41,21 @@ impl PyValue for PyDict {
41
41
#[ pyimpl( flags( BASETYPE ) ) ]
42
42
impl PyDictRef {
43
43
#[ pyslot]
44
- fn tp_new (
45
- class : PyClassRef ,
44
+ fn tp_new ( class : PyClassRef , _args : PyFuncArgs , vm : & VirtualMachine ) -> PyResult < PyDictRef > {
45
+ PyDict {
46
+ entries : RefCell :: new ( DictContentType :: default ( ) ) ,
47
+ }
48
+ . into_ref_with_type ( vm, class)
49
+ }
50
+
51
+ #[ pymethod( magic) ]
52
+ fn init (
53
+ self ,
46
54
dict_obj : OptionalArg < PyObjectRef > ,
47
55
kwargs : KwArgs ,
48
56
vm : & VirtualMachine ,
49
- ) -> PyResult < PyDictRef > {
50
- let dict = DictContentType :: default ( ) ;
51
-
52
- let entries = RefCell :: new ( dict) ;
53
- // it's unfortunate that we can't abstract over RefCall, as we should be able to use dict
54
- // directly here, but that would require generic associated types
55
- PyDictRef :: merge ( & entries, dict_obj, kwargs, vm) ?;
56
-
57
- PyDict { entries } . into_ref_with_type ( vm, class)
57
+ ) -> PyResult < ( ) > {
58
+ PyDictRef :: merge ( & self . entries , dict_obj, kwargs, vm)
58
59
}
59
60
60
61
fn merge (
0 commit comments