@@ -59,7 +59,8 @@ mod _ssl {
5959 } ;
6060 use crate :: {
6161 common:: lock:: {
62- PyMappedRwLockReadGuard , PyMutex , PyRwLock , PyRwLockReadGuard , PyRwLockWriteGuard ,
62+ LazyLock , PyMappedRwLockReadGuard , PyMutex , PyRwLock , PyRwLockReadGuard ,
63+ PyRwLockWriteGuard ,
6364 } ,
6465 socket:: { self , PySocket } ,
6566 vm:: {
@@ -1046,7 +1047,7 @@ mod _ssl {
10461047
10471048 #[ pymethod]
10481049 fn set_ciphers ( & self , cipherlist : PyStrRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
1049- let ciphers = cipherlist. as_str ( ) ;
1050+ let ciphers: & str = cipherlist. as_ref ( ) ;
10501051 if ciphers. contains ( '\0' ) {
10511052 return Err ( exceptions:: cstring_error ( vm) ) ;
10521053 }
@@ -1102,7 +1103,8 @@ mod _ssl {
11021103 // Convert name to CString, supporting both str and bytes
11031104 let name_cstr = match name {
11041105 Either :: A ( s) => {
1105- if s. as_str ( ) . contains ( '\0' ) {
1106+ let s: & str = s. as_ref ( ) ;
1107+ if s. contains ( '\0' ) {
11061108 return Err ( exceptions:: cstring_error ( vm) ) ;
11071109 }
11081110 s. to_cstring ( vm) ?
@@ -1459,7 +1461,7 @@ mod _ssl {
14591461 }
14601462 * self . psk_server_callback . lock ( ) = Some ( callback) ;
14611463 if let OptionalArg :: Present ( hint) = identity_hint {
1462- * self . psk_identity_hint . lock ( ) = Some ( hint. as_str ( ) . to_owned ( ) ) ;
1464+ * self . psk_identity_hint . lock ( ) = Some ( hint. to_string ( ) ) ;
14631465 }
14641466 // Note: The actual callback will be invoked via SSL app_data mechanism
14651467 }
@@ -1487,7 +1489,8 @@ mod _ssl {
14871489 if let Some ( cadata) = args. cadata {
14881490 let ( certs, is_pem) = match cadata {
14891491 Either :: A ( s) => {
1490- if !s. as_str ( ) . is_ascii ( ) {
1492+ let s: & str = s. as_ref ( ) ;
1493+ if !s. is_ascii ( ) {
14911494 return Err ( invalid_cadata ( vm) ) ;
14921495 }
14931496 ( X509 :: stack_from_pem ( s. as_bytes ( ) ) , true )
@@ -1977,7 +1980,7 @@ mod _ssl {
19771980 use crate :: vm:: builtins:: { PyByteArray , PyBytes , PyStr } ;
19781981
19791982 if let Some ( s) = obj. downcast_ref :: < PyStr > ( ) {
1980- Ok ( s. as_str ( ) . as_bytes ( ) . to_vec ( ) )
1983+ Ok ( s. as_bytes ( ) . to_vec ( ) )
19811984 } else if let Some ( b) = obj. downcast_ref :: < PyBytes > ( ) {
19821985 Ok ( b. as_bytes ( ) . to_vec ( ) )
19831986 } else if let Some ( ba) = obj. downcast_ref :: < PyByteArray > ( ) {
@@ -2033,7 +2036,7 @@ mod _ssl {
20332036
20342037 // Configure server hostname
20352038 if let Some ( hostname) = & server_hostname {
2036- let hostname_str = hostname. as_str ( ) ;
2039+ let hostname_str: & str = hostname. as_ref ( ) ;
20372040 if hostname_str. is_empty ( ) || hostname_str. starts_with ( '.' ) {
20382041 return Err ( vm. new_value_error (
20392042 "server_hostname cannot be an empty string or start with a leading dot." ,
@@ -2752,7 +2755,7 @@ mod _ssl {
27522755 ) -> PyResult < Option < PyBytesRef > > {
27532756 const CB_MAXLEN : usize = 512 ;
27542757
2755- let cb_type_str = cb_type. as_ref ( ) . map_or ( "tls-unique" , |s| s. as_str ( ) ) ;
2758+ let cb_type_str = cb_type. as_ref ( ) . map_or ( "tls-unique" , |s| s. as_ref ( ) ) ;
27562759
27572760 if cb_type_str != "tls-unique" {
27582761 return Err ( vm. new_value_error ( format ! (
0 commit comments