@@ -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 } ;
@@ -800,14 +801,10 @@ impl VirtualMachine {
800
801
syntax_error
801
802
}
802
803
803
- pub fn new_import_error (
804
- & self ,
805
- msg : String ,
806
- name : impl TryIntoRef < PyStr > ,
807
- ) -> PyBaseExceptionRef {
804
+ pub fn new_import_error ( & self , msg : String , name : impl IntoPyStrRef ) -> PyBaseExceptionRef {
808
805
let import_error = self . ctx . exceptions . import_error . clone ( ) ;
809
806
let exc = self . new_exception_msg ( import_error, msg) ;
810
- self . set_attr ( exc. as_object ( ) , "name" , name. try_into_ref ( self ) )
807
+ self . set_attr ( exc. as_object ( ) , "name" , name. into_pystr_ref ( self ) )
811
808
. unwrap ( ) ;
812
809
exc
813
810
}
@@ -938,11 +935,11 @@ impl VirtualMachine {
938
935
#[ inline]
939
936
pub fn import (
940
937
& self ,
941
- module : impl TryIntoRef < PyStr > ,
938
+ module : impl IntoPyStrRef ,
942
939
from_list : Option < PyTupleTyped < PyStrRef > > ,
943
940
level : usize ,
944
941
) -> PyResult {
945
- self . _import_inner ( module. try_into_ref ( self ) , from_list, level)
942
+ self . _import_inner ( module. into_pystr_ref ( self ) , from_list, level)
946
943
}
947
944
948
945
fn _import_inner (
@@ -1399,9 +1396,9 @@ impl VirtualMachine {
1399
1396
#[ cfg_attr( feature = "flame-it" , flame( "VirtualMachine" ) ) ]
1400
1397
pub fn get_attribute < T > ( & self , obj : PyObjectRef , attr_name : T ) -> PyResult
1401
1398
where
1402
- T : TryIntoRef < PyStr > ,
1399
+ T : IntoPyStrRef ,
1403
1400
{
1404
- let attr_name = attr_name. try_into_ref ( self ) ;
1401
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1405
1402
vm_trace ! ( "vm.__getattribute__: {:?} {:?}" , obj, attr_name) ;
1406
1403
let getattro = obj
1407
1404
. class ( )
@@ -1416,7 +1413,7 @@ impl VirtualMachine {
1416
1413
attr_name : T ,
1417
1414
) -> PyResult < Option < PyObjectRef > >
1418
1415
where
1419
- T : TryIntoRef < PyStr > ,
1416
+ T : IntoPyStrRef ,
1420
1417
{
1421
1418
match self . get_attribute ( obj, attr_name) {
1422
1419
Ok ( attr) => Ok ( Some ( attr) ) ,
@@ -1451,15 +1448,15 @@ impl VirtualMachine {
1451
1448
1452
1449
pub fn set_attr < K , V > ( & self , obj : & PyObjectRef , attr_name : K , attr_value : V ) -> PyResult < ( ) >
1453
1450
where
1454
- K : TryIntoRef < PyStr > ,
1451
+ K : IntoPyStrRef ,
1455
1452
V : Into < PyObjectRef > ,
1456
1453
{
1457
- let attr_name = attr_name. try_into_ref ( self ) ;
1454
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1458
1455
self . call_set_attr ( obj, attr_name, Some ( attr_value. into ( ) ) )
1459
1456
}
1460
1457
1461
- pub fn del_attr ( & self , obj : & PyObjectRef , attr_name : impl TryIntoRef < PyStr > ) -> PyResult < ( ) > {
1462
- let attr_name = attr_name. try_into_ref ( self ) ;
1458
+ pub fn del_attr ( & self , obj : & PyObjectRef , attr_name : impl IntoPyStrRef ) -> PyResult < ( ) > {
1459
+ let attr_name = attr_name. into_pystr_ref ( self ) ;
1463
1460
self . call_set_attr ( obj, attr_name, None )
1464
1461
}
1465
1462
@@ -2169,11 +2166,11 @@ impl VirtualMachine {
2169
2166
pub fn __module_set_attr (
2170
2167
& self ,
2171
2168
module : & PyObjectRef ,
2172
- attr_name : impl TryIntoRef < PyStr > ,
2169
+ attr_name : impl IntoPyStrRef ,
2173
2170
attr_value : impl Into < PyObjectRef > ,
2174
2171
) -> PyResult < ( ) > {
2175
2172
let val = attr_value. into ( ) ;
2176
- object:: setattr ( module, attr_name. try_into_ref ( self ) , Some ( val) , self )
2173
+ object:: setattr ( module, attr_name. into_pystr_ref ( self ) , Some ( val) , self )
2177
2174
}
2178
2175
}
2179
2176
0 commit comments