@@ -151,7 +151,7 @@ pub(crate) mod _asyncio {
151151 fn init ( zelf : PyRef < Self > , args : Self :: Args , vm : & VirtualMachine ) -> PyResult < ( ) > {
152152 // Future does not accept positional arguments
153153 if !args. args . is_empty ( ) {
154- return Err ( vm. new_type_error ( "Future() takes no positional arguments" . to_string ( ) ) ) ;
154+ return Err ( vm. new_type_error ( "Future() takes no positional arguments" ) ) ;
155155 }
156156 // Extract only 'loop' keyword argument
157157 let loop_ = args. kwargs . get ( "loop" ) . cloned ( ) ;
@@ -265,7 +265,7 @@ pub(crate) mod _asyncio {
265265 #[ pymethod]
266266 fn set_result ( zelf : PyRef < Self > , result : PyObjectRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
267267 if zelf. fut_loop . read ( ) . is_none ( ) {
268- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
268+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
269269 }
270270 if zelf. fut_state . load ( ) != FutureState :: Pending {
271271 return Err ( new_invalid_state_error ( vm, "invalid state" ) ) ;
@@ -283,7 +283,7 @@ pub(crate) mod _asyncio {
283283 vm : & VirtualMachine ,
284284 ) -> PyResult < ( ) > {
285285 if zelf. fut_loop . read ( ) . is_none ( ) {
286- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
286+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
287287 }
288288 if zelf. fut_state . load ( ) != FutureState :: Pending {
289289 return Err ( new_invalid_state_error ( vm, "invalid state" ) ) ;
@@ -336,7 +336,7 @@ pub(crate) mod _asyncio {
336336 vm : & VirtualMachine ,
337337 ) -> PyResult < ( ) > {
338338 if zelf. fut_loop . read ( ) . is_none ( ) {
339- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
339+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
340340 }
341341 let ctx = match args. context . flatten ( ) {
342342 Some ( c) => c,
@@ -364,7 +364,7 @@ pub(crate) mod _asyncio {
364364 #[ pymethod]
365365 fn remove_done_callback ( & self , func : PyObjectRef , vm : & VirtualMachine ) -> PyResult < usize > {
366366 if self . fut_loop . read ( ) . is_none ( ) {
367- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
367+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
368368 }
369369 let mut cleared_callback0 = 0usize ;
370370
@@ -461,7 +461,7 @@ pub(crate) mod _asyncio {
461461 #[ pymethod]
462462 fn cancel ( zelf : PyRef < Self > , args : CancelArgs , vm : & VirtualMachine ) -> PyResult < bool > {
463463 if zelf. fut_loop . read ( ) . is_none ( ) {
464- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
464+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
465465 }
466466 if zelf. fut_state . load ( ) != FutureState :: Pending {
467467 // Clear log_tb even when cancel fails
@@ -598,9 +598,7 @@ pub(crate) mod _asyncio {
598598 self . fut_blocking . store ( v, Ordering :: Relaxed ) ;
599599 Ok ( ( ) )
600600 }
601- PySetterValue :: Delete => {
602- Err ( vm. new_attribute_error ( "cannot delete attribute" . to_string ( ) ) )
603- }
601+ PySetterValue :: Delete => Err ( vm. new_attribute_error ( "cannot delete attribute" ) ) ,
604602 }
605603 }
606604
@@ -670,16 +668,12 @@ pub(crate) mod _asyncio {
670668 match value {
671669 PySetterValue :: Assign ( v) => {
672670 if v {
673- return Err ( vm. new_value_error (
674- "_log_traceback can only be set to False" . to_string ( ) ,
675- ) ) ;
671+ return Err ( vm. new_value_error ( "_log_traceback can only be set to False" ) ) ;
676672 }
677673 self . fut_log_tb . store ( false , Ordering :: Relaxed ) ;
678674 Ok ( ( ) )
679675 }
680- PySetterValue :: Delete => {
681- Err ( vm. new_attribute_error ( "cannot delete attribute" . to_string ( ) ) )
682- }
676+ PySetterValue :: Delete => Err ( vm. new_attribute_error ( "cannot delete attribute" ) ) ,
683677 }
684678 }
685679
@@ -1055,7 +1049,7 @@ pub(crate) mod _asyncio {
10551049 // Must be a subclass of BaseException
10561050 if !exc_class. fast_issubclass ( vm. ctx . exceptions . base_exception_type ) {
10571051 return Err ( vm. new_type_error (
1058- "exceptions must be classes or instances deriving from BaseException, not type" . to_string ( )
1052+ "exceptions must be classes or instances deriving from BaseException, not type"
10591053 ) ) ;
10601054 }
10611055
@@ -1072,9 +1066,9 @@ pub(crate) mod _asyncio {
10721066 if let OptionalArg :: Present ( ref val) = exc_val
10731067 && !vm. is_none ( val)
10741068 {
1075- return Err ( vm . new_type_error (
1076- "instance exception may not have a separate value" . to_string ( ) ,
1077- ) ) ;
1069+ return Err (
1070+ vm . new_type_error ( "instance exception may not have a separate value" )
1071+ ) ;
10781072 }
10791073 exc_type
10801074 } else {
@@ -1339,7 +1333,7 @@ pub(crate) mod _asyncio {
13391333 vm : & VirtualMachine ,
13401334 ) -> PyResult < ( ) > {
13411335 if zelf. base . fut_loop . read ( ) . is_none ( ) {
1342- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
1336+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
13431337 }
13441338 let ctx = match args. context . flatten ( ) {
13451339 Some ( c) => c,
@@ -1367,7 +1361,7 @@ pub(crate) mod _asyncio {
13671361 #[ pymethod]
13681362 fn remove_done_callback ( & self , func : PyObjectRef , vm : & VirtualMachine ) -> PyResult < usize > {
13691363 if self . base . fut_loop . read ( ) . is_none ( ) {
1370- return Err ( vm. new_runtime_error ( "Future object is not initialized." . to_string ( ) ) ) ;
1364+ return Err ( vm. new_runtime_error ( "Future object is not initialized." ) ) ;
13711365 }
13721366 let mut cleared_callback0 = 0usize ;
13731367
@@ -1686,9 +1680,7 @@ pub(crate) mod _asyncio {
16861680 self . base . fut_blocking . store ( v, Ordering :: Relaxed ) ;
16871681 Ok ( ( ) )
16881682 }
1689- PySetterValue :: Delete => {
1690- Err ( vm. new_attribute_error ( "cannot delete attribute" . to_string ( ) ) )
1691- }
1683+ PySetterValue :: Delete => Err ( vm. new_attribute_error ( "cannot delete attribute" ) ) ,
16921684 }
16931685 }
16941686
@@ -1718,7 +1710,7 @@ pub(crate) mod _asyncio {
17181710 Ok ( ( ) )
17191711 }
17201712 PySetterValue :: Delete => {
1721- Err ( vm. new_attribute_error ( "can't delete _log_destroy_pending" . to_owned ( ) ) )
1713+ Err ( vm. new_attribute_error ( "can't delete _log_destroy_pending" ) )
17221714 }
17231715 }
17241716 }
@@ -1737,16 +1729,12 @@ pub(crate) mod _asyncio {
17371729 match value {
17381730 PySetterValue :: Assign ( v) => {
17391731 if v {
1740- return Err ( vm. new_value_error (
1741- "_log_traceback can only be set to False" . to_string ( ) ,
1742- ) ) ;
1732+ return Err ( vm. new_value_error ( "_log_traceback can only be set to False" ) ) ;
17431733 }
17441734 self . base . fut_log_tb . store ( false , Ordering :: Relaxed ) ;
17451735 Ok ( ( ) )
17461736 }
1747- PySetterValue :: Delete => {
1748- Err ( vm. new_attribute_error ( "cannot delete attribute" . to_string ( ) ) )
1749- }
1737+ PySetterValue :: Delete => Err ( vm. new_attribute_error ( "cannot delete attribute" ) ) ,
17501738 }
17511739 }
17521740
@@ -2532,14 +2520,10 @@ pub(crate) mod _asyncio {
25322520 let running_task = vm. asyncio_running_task . borrow ( ) ;
25332521 match running_task. as_ref ( ) {
25342522 None => {
2535- return Err ( vm. new_runtime_error (
2536- "_leave_task: task is not the current task" . to_owned ( ) ,
2537- ) ) ;
2523+ return Err ( vm. new_runtime_error ( "_leave_task: task is not the current task" ) ) ;
25382524 }
25392525 Some ( current) if !current. is ( & task) => {
2540- return Err ( vm. new_runtime_error (
2541- "_leave_task: task is not the current task" . to_owned ( ) ,
2542- ) ) ;
2526+ return Err ( vm. new_runtime_error ( "_leave_task: task is not the current task" ) ) ;
25432527 }
25442528 _ => { }
25452529 }
@@ -2777,7 +2761,7 @@ pub(crate) mod _asyncio {
27772761 . ok_or_else ( || vm. new_attribute_error ( "CancelledError not found" ) ) ?;
27782762 exc_type
27792763 . downcast ( )
2780- . map_err ( |_| vm. new_type_error ( "CancelledError is not a type" . to_string ( ) ) )
2764+ . map_err ( |_| vm. new_type_error ( "CancelledError is not a type" ) )
27812765 }
27822766
27832767 fn is_cancelled_error ( exc : & PyBaseExceptionRef , vm : & VirtualMachine ) -> bool {
0 commit comments