@@ -11,7 +11,7 @@ mod mmap {
1111 use crate :: vm:: {
1212 AsObject , FromArgs , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult ,
1313 TryFromBorrowedObject , VirtualMachine , atomic_func,
14- builtins:: { PyBytes , PyBytesRef , PyInt , PyIntRef , PyTypeRef } ,
14+ builtins:: { PyBytes , PyBytesRef , PyInt , PyIntRef , PyType , PyTypeRef } ,
1515 byte:: { bytes_from_object, value_from_object} ,
1616 convert:: ToPyException ,
1717 function:: { ArgBytesLike , FuncArgs , OptionalArg } ,
@@ -388,7 +388,7 @@ mod mmap {
388388 type Args = MmapNewArgs ;
389389
390390 #[ cfg( unix) ]
391- fn py_new ( cls : PyTypeRef , args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
391+ fn py_new ( _cls : & Py < PyType > , args : Self :: Args , vm : & VirtualMachine ) -> PyResult < Self > {
392392 use libc:: { MAP_PRIVATE , MAP_SHARED , PROT_READ , PROT_WRITE } ;
393393
394394 let mut map_size = args. validate_new_args ( vm) ?;
@@ -477,7 +477,7 @@ mod mmap {
477477 } ( )
478478 . map_err ( |e| e. to_pyexception ( vm) ) ?;
479479
480- let m_obj = Self {
480+ Ok ( Self {
481481 closed : AtomicCell :: new ( false ) ,
482482 mmap : PyMutex :: new ( Some ( mmap) ) ,
483483 fd : AtomicCell :: new ( fd. map_or ( -1 , |fd| fd. into_raw ( ) ) ) ,
@@ -486,13 +486,11 @@ mod mmap {
486486 pos : AtomicCell :: new ( 0 ) ,
487487 exports : AtomicCell :: new ( 0 ) ,
488488 access,
489- } ;
490-
491- m_obj. into_ref_with_type ( vm, cls) . map ( Into :: into)
489+ } )
492490 }
493491
494492 #[ cfg( windows) ]
495- fn py_new ( cls : PyTypeRef , args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
493+ fn py_new ( _cls : & Py < PyType > , args : Self :: Args , vm : & VirtualMachine ) -> PyResult < Self > {
496494 let mut map_size = args. validate_new_args ( vm) ?;
497495 let MmapNewArgs {
498496 fileno,
@@ -627,7 +625,7 @@ mod mmap {
627625 ( INVALID_HANDLE_VALUE as isize , MmapObj :: Write ( mmap) )
628626 } ;
629627
630- let m_obj = Self {
628+ Ok ( Self {
631629 closed : AtomicCell :: new ( false ) ,
632630 mmap : PyMutex :: new ( Some ( mmap) ) ,
633631 handle : AtomicCell :: new ( handle) ,
@@ -636,9 +634,7 @@ mod mmap {
636634 pos : AtomicCell :: new ( 0 ) ,
637635 exports : AtomicCell :: new ( 0 ) ,
638636 access,
639- } ;
640-
641- m_obj. into_ref_with_type ( vm, cls) . map ( Into :: into)
637+ } )
642638 }
643639 }
644640
0 commit comments