@@ -302,7 +302,7 @@ mod _sqlite {
302302 isolation_level : Option < PyStrRef > ,
303303 #[ pyarg( any, default = "true" ) ]
304304 check_same_thread : bool ,
305- #[ pyarg( any, default = "Connection::class(vm ).to_owned()" ) ]
305+ #[ pyarg( any, default = "Connection::class(&vm.ctx ).to_owned()" ) ]
306306 factory : PyTypeRef ,
307307 // TODO: cache statements
308308 #[ allow( dead_code) ]
@@ -640,14 +640,14 @@ mod _sqlite {
640640
641641 #[ pyfunction]
642642 fn register_adapter ( typ : PyTypeRef , adapter : ArgCallable , vm : & VirtualMachine ) -> PyResult < ( ) > {
643- if typ. is ( PyInt :: class ( vm ) )
644- || typ. is ( PyFloat :: class ( vm ) )
645- || typ. is ( PyStr :: class ( vm ) )
646- || typ. is ( PyByteArray :: class ( vm ) )
643+ if typ. is ( PyInt :: class ( & vm . ctx ) )
644+ || typ. is ( PyFloat :: class ( & vm . ctx ) )
645+ || typ. is ( PyStr :: class ( & vm . ctx ) )
646+ || typ. is ( PyByteArray :: class ( & vm . ctx ) )
647647 {
648648 let _ = BASE_TYPE_ADAPTED . set ( ( ) ) ;
649649 }
650- let protocol = PrepareProtocol :: class ( vm ) . to_owned ( ) ;
650+ let protocol = PrepareProtocol :: class ( & vm . ctx ) . to_owned ( ) ;
651651 let key = vm. ctx . new_tuple ( vec ! [ typ. into( ) , protocol. into( ) ] ) ;
652652 adapters ( ) . set_item ( key. as_object ( ) , adapter. into ( ) , vm)
653653 }
@@ -708,7 +708,7 @@ mod _sqlite {
708708 // TODO: None proto
709709 let proto = proto
710710 . flatten ( )
711- . unwrap_or_else ( || PrepareProtocol :: class ( vm ) . to_owned ( ) ) ;
711+ . unwrap_or_else ( || PrepareProtocol :: class ( & vm . ctx ) . to_owned ( ) ) ;
712712
713713 _adapt (
714714 & obj,
@@ -818,7 +818,7 @@ mod _sqlite {
818818
819819 fn call ( zelf : & Py < Self > , args : Self :: Args , vm : & VirtualMachine ) -> PyResult {
820820 if let Some ( stmt) = Statement :: new ( zelf, & args. 0 , vm) ? {
821- Ok ( stmt. into_ref ( vm ) . into ( ) )
821+ Ok ( stmt. into_ref ( & vm . ctx ) . into ( ) )
822822 } else {
823823 Ok ( vm. ctx . none ( ) )
824824 }
@@ -835,7 +835,7 @@ mod _sqlite {
835835 if let Some ( isolation_level) = & args. isolation_level {
836836 begin_statement_ptr_from_isolation_level ( isolation_level, vm) ?;
837837 }
838- let text_factory = PyStr :: class ( vm ) . to_owned ( ) . into_object ( ) ;
838+ let text_factory = PyStr :: class ( & vm . ctx ) . to_owned ( ) . into_object ( ) ;
839839
840840 Ok ( Self {
841841 db : PyMutex :: new ( Some ( db) ) ,
@@ -884,7 +884,7 @@ mod _sqlite {
884884 cursor
885885 } else {
886886 let row_factory = zelf. row_factory . to_owned ( ) ;
887- Cursor :: new ( zelf, row_factory, vm) . into_ref ( vm )
887+ Cursor :: new ( zelf, row_factory, vm) . into_ref ( & vm . ctx )
888888 } ;
889889 Ok ( cursor)
890890 }
@@ -921,7 +921,7 @@ mod _sqlite {
921921 connection : zelf,
922922 inner : PyMutex :: new ( Some ( BlobInner { blob, offset : 0 } ) ) ,
923923 } ;
924- Ok ( blob. into_ref ( vm ) )
924+ Ok ( blob. into_ref ( & vm . ctx ) )
925925 }
926926
927927 #[ pymethod]
@@ -954,7 +954,7 @@ mod _sqlite {
954954 vm : & VirtualMachine ,
955955 ) -> PyResult < PyRef < Cursor > > {
956956 let row_factory = zelf. row_factory . to_owned ( ) ;
957- let cursor = Cursor :: new ( zelf, row_factory, vm) . into_ref ( vm ) ;
957+ let cursor = Cursor :: new ( zelf, row_factory, vm) . into_ref ( & vm . ctx ) ;
958958 Cursor :: execute ( cursor, sql, parameters, vm)
959959 }
960960
@@ -966,7 +966,7 @@ mod _sqlite {
966966 vm : & VirtualMachine ,
967967 ) -> PyResult < PyRef < Cursor > > {
968968 let row_factory = zelf. row_factory . to_owned ( ) ;
969- let cursor = Cursor :: new ( zelf, row_factory, vm) . into_ref ( vm ) ;
969+ let cursor = Cursor :: new ( zelf, row_factory, vm) . into_ref ( & vm . ctx ) ;
970970 Cursor :: executemany ( cursor, sql, seq_of_params, vm)
971971 }
972972
@@ -977,7 +977,11 @@ mod _sqlite {
977977 vm : & VirtualMachine ,
978978 ) -> PyResult < PyRef < Cursor > > {
979979 let row_factory = zelf. row_factory . to_owned ( ) ;
980- Cursor :: executescript ( Cursor :: new ( zelf, row_factory, vm) . into_ref ( vm) , script, vm)
980+ Cursor :: executescript (
981+ Cursor :: new ( zelf, row_factory, vm) . into_ref ( & vm. ctx ) ,
982+ script,
983+ vm,
984+ )
981985 }
982986
983987 #[ pymethod]
@@ -1403,7 +1407,7 @@ mod _sqlite {
14031407 drop ( inner) ;
14041408 return Ok ( zelf) ;
14051409 } ;
1406- let stmt = stmt. into_ref ( vm ) ;
1410+ let stmt = stmt. into_ref ( & vm . ctx ) ;
14071411
14081412 inner. rowcount = if stmt. is_dml { 0 } else { -1 } ;
14091413
@@ -1472,7 +1476,7 @@ mod _sqlite {
14721476 drop ( inner) ;
14731477 return Ok ( zelf) ;
14741478 } ;
1475- let stmt = stmt. into_ref ( vm ) ;
1479+ let stmt = stmt. into_ref ( & vm . ctx ) ;
14761480
14771481 let st = stmt. lock ( ) ;
14781482
@@ -1724,15 +1728,15 @@ mod _sqlite {
17241728
17251729 let text_factory = zelf. connection . text_factory . to_owned ( ) ;
17261730
1727- if text_factory. is ( PyStr :: class ( vm ) ) {
1731+ if text_factory. is ( PyStr :: class ( & vm . ctx ) ) {
17281732 let text = String :: from_utf8 ( text) . map_err ( |_| {
17291733 new_operational_error ( vm, "not valid UTF-8" . to_owned ( ) )
17301734 } ) ?;
17311735 vm. ctx . new_str ( text) . into ( )
1732- } else if text_factory. is ( PyBytes :: class ( vm ) ) {
1736+ } else if text_factory. is ( PyBytes :: class ( & vm . ctx ) ) {
17331737 vm. ctx . new_bytes ( text) . into ( )
1734- } else if text_factory. is ( PyByteArray :: class ( vm ) ) {
1735- PyByteArray :: from ( text) . into_ref ( vm ) . into ( )
1738+ } else if text_factory. is ( PyByteArray :: class ( & vm . ctx ) ) {
1739+ PyByteArray :: from ( text) . into_ref ( & vm . ctx ) . into ( )
17361740 } else {
17371741 let bytes = vm. ctx . new_bytes ( text) ;
17381742 text_factory. call ( ( bytes, ) , vm) ?
@@ -2531,7 +2535,7 @@ mod _sqlite {
25312535 let obj = if need_adapt ( parameter, vm) {
25322536 adapted = _adapt (
25332537 parameter,
2534- PrepareProtocol :: class ( vm ) . to_owned ( ) ,
2538+ PrepareProtocol :: class ( & vm . ctx ) . to_owned ( ) ,
25352539 |x| Ok ( x. to_owned ( ) ) ,
25362540 vm,
25372541 ) ?;
0 commit comments