@@ -10,6 +10,7 @@ use crate::{
10
10
builtins:: {
11
11
code:: { self , PyCode } ,
12
12
module, object,
13
+ pystr:: IntoPyStrRef ,
13
14
tuple:: { IntoPyTuple , PyTuple , PyTupleRef , PyTupleTyped } ,
14
15
PyBaseException , PyBaseExceptionRef , PyDictRef , PyInt , PyIntRef , PyList , PyModule , PyStr ,
15
16
PyStrRef , PyTypeRef ,
@@ -29,7 +30,7 @@ use crate::{
29
30
stdlib,
30
31
utils:: Either ,
31
32
IdProtocol , ItemProtocol , PyArithmeticValue , PyContext , PyLease , PyMethod , PyObject ,
32
- PyObjectRef , PyRef , PyRefExact , PyResult , PyValue , TryFromObject , TryIntoRef , TypeProtocol ,
33
+ PyObjectRef , PyRef , PyRefExact , PyResult , PyValue , TryFromObject , TypeProtocol ,
33
34
} ;
34
35
use crossbeam_utils:: atomic:: AtomicCell ;
35
36
use num_traits:: { Signed , ToPrimitive } ;
@@ -781,14 +782,10 @@ impl VirtualMachine {
781
782
syntax_error
782
783
}
783
784
784
- pub fn new_import_error (
785
- & self ,
786
- msg : String ,
787
- name : impl TryIntoRef < PyStr > ,
788
- ) -> PyBaseExceptionRef {
785
+ pub fn new_import_error ( & self , msg : String , name : impl IntoPyStrRef ) -> PyBaseExceptionRef {
789
786
let import_error = self . ctx . exceptions . import_error . clone ( ) ;
790
787
let exc = self . new_exception_msg ( import_error, msg) ;
791
- self . set_attr ( exc. as_object ( ) , "name" , name. try_into_ref ( self ) )
788
+ self . set_attr ( exc. as_object ( ) , "name" , name. into_pystr_ref ( self ) )
792
789
. unwrap ( ) ;
793
790
exc
794
791
}
@@ -917,11 +914,11 @@ impl VirtualMachine {
917
914
#[ inline]
918
915
pub fn import (
919
916
& self ,
920
- module : impl TryIntoRef < PyStr > ,
917
+ module : impl IntoPyStrRef ,
921
918
from_list : Option < PyTupleTyped < PyStrRef > > ,
922
919
level : usize ,
923
920
) -> PyResult {
924
- self . _import_inner ( module. try_into_ref ( self ) , from_list, level)
921
+ self . _import_inner ( module. into_pystr_ref ( self ) , from_list, level)
925
922
}
926
923
927
924
fn _import_inner (
@@ -1364,9 +1361,9 @@ impl VirtualMachine {
1364
1361
#[ cfg_attr( feature = "flame-it" , flame( "VirtualMachine" ) ) ]
1365
1362
pub fn get_attribute < T > ( & self , obj : PyObjectRef , attr_name : T ) -> PyResult
1366
1363
where
1367
- T : TryIntoRef < PyStr > ,
1364
+ T : IntoPyStrRef ,
1368
1365
{
1369
- let attr_name = attr_name. try_into_ref ( self ) ;
1366
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1370
1367
vm_trace ! ( "vm.__getattribute__: {:?} {:?}" , obj, attr_name) ;
1371
1368
let getattro = obj
1372
1369
. class ( )
@@ -1381,7 +1378,7 @@ impl VirtualMachine {
1381
1378
attr_name : T ,
1382
1379
) -> PyResult < Option < PyObjectRef > >
1383
1380
where
1384
- T : TryIntoRef < PyStr > ,
1381
+ T : IntoPyStrRef ,
1385
1382
{
1386
1383
match self . get_attribute ( obj, attr_name) {
1387
1384
Ok ( attr) => Ok ( Some ( attr) ) ,
@@ -1416,15 +1413,15 @@ impl VirtualMachine {
1416
1413
1417
1414
pub fn set_attr < K , V > ( & self , obj : & PyObjectRef , attr_name : K , attr_value : V ) -> PyResult < ( ) >
1418
1415
where
1419
- K : TryIntoRef < PyStr > ,
1416
+ K : IntoPyStrRef ,
1420
1417
V : Into < PyObjectRef > ,
1421
1418
{
1422
- let attr_name = attr_name. try_into_ref ( self ) ;
1419
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1423
1420
self . call_set_attr ( obj, attr_name, Some ( attr_value. into ( ) ) )
1424
1421
}
1425
1422
1426
- pub fn del_attr ( & self , obj : & PyObjectRef , attr_name : impl TryIntoRef < PyStr > ) -> PyResult < ( ) > {
1427
- let attr_name = attr_name. try_into_ref ( self ) ;
1423
+ pub fn del_attr ( & self , obj : & PyObjectRef , attr_name : impl IntoPyStrRef ) -> PyResult < ( ) > {
1424
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1428
1425
self . call_set_attr ( obj, attr_name, None )
1429
1426
}
1430
1427
@@ -2134,11 +2131,11 @@ impl VirtualMachine {
2134
2131
pub fn __module_set_attr (
2135
2132
& self ,
2136
2133
module : & PyObjectRef ,
2137
- attr_name : impl TryIntoRef < PyStr > ,
2134
+ attr_name : impl IntoPyStrRef ,
2138
2135
attr_value : impl Into < PyObjectRef > ,
2139
2136
) -> PyResult < ( ) > {
2140
2137
let val = attr_value. into ( ) ;
2141
- object:: setattr ( module, attr_name. try_into_ref ( self ) , Some ( val) , self )
2138
+ object:: setattr ( module, attr_name. into_pystr_ref ( self ) , Some ( val) , self )
2142
2139
}
2143
2140
}
2144
2141
0 commit comments