@@ -73,40 +73,34 @@ impl<'a> PyStringData<'a> {
7373        match  self  { 
7474            Self :: Ucs1 ( data)  => match  str:: from_utf8 ( data)  { 
7575                Ok ( s)  => Ok ( Cow :: Borrowed ( s) ) , 
76-                 Err ( e)  => Err ( crate :: PyErr :: from_value_bound ( 
77-                     PyUnicodeDecodeError :: new_utf8_bound ( py,  data,  e) ?. into_any ( ) , 
78-                 ) ) , 
76+                 Err ( e)  => Err ( PyUnicodeDecodeError :: new_utf8_bound ( py,  data,  e) ?. into ( ) ) , 
7977            } , 
8078            Self :: Ucs2 ( data)  => match  String :: from_utf16 ( data)  { 
8179                Ok ( s)  => Ok ( Cow :: Owned ( s) ) , 
8280                Err ( e)  => { 
8381                    let  mut  message = e. to_string ( ) . as_bytes ( ) . to_vec ( ) ; 
8482                    message. push ( 0 ) ; 
8583
86-                     Err ( crate :: PyErr :: from_value_bound ( 
87-                         PyUnicodeDecodeError :: new_bound ( 
88-                             py, 
89-                             CStr :: from_bytes_with_nul ( b"utf-16\0 " ) . unwrap ( ) , 
90-                             self . as_bytes ( ) , 
91-                             0 ..self . as_bytes ( ) . len ( ) , 
92-                             CStr :: from_bytes_with_nul ( & message) . unwrap ( ) , 
93-                         ) ?
94-                         . into_any ( ) , 
95-                     ) ) 
96-                 } 
97-             } , 
98-             Self :: Ucs4 ( data)  => match  data. iter ( ) . map ( |& c| std:: char:: from_u32 ( c) ) . collect ( )  { 
99-                 Some ( s)  => Ok ( Cow :: Owned ( s) ) , 
100-                 None  => Err ( crate :: PyErr :: from_value_bound ( 
101-                     PyUnicodeDecodeError :: new_bound ( 
84+                     Err ( PyUnicodeDecodeError :: new_bound ( 
10285                        py, 
103-                         CStr :: from_bytes_with_nul ( b"utf-32 \0 " ) . unwrap ( ) , 
86+                         CStr :: from_bytes_with_nul ( b"utf-16 \0 " ) . unwrap ( ) , 
10487                        self . as_bytes ( ) , 
10588                        0 ..self . as_bytes ( ) . len ( ) , 
106-                         CStr :: from_bytes_with_nul ( b"error converting utf-32 \0 " ) . unwrap ( ) , 
89+                         CStr :: from_bytes_with_nul ( & message ) . unwrap ( ) , 
10790                    ) ?
108-                     . into_any ( ) , 
109-                 ) ) , 
91+                     . into ( ) ) 
92+                 } 
93+             } , 
94+             Self :: Ucs4 ( data)  => match  data. iter ( ) . map ( |& c| std:: char:: from_u32 ( c) ) . collect ( )  { 
95+                 Some ( s)  => Ok ( Cow :: Owned ( s) ) , 
96+                 None  => Err ( PyUnicodeDecodeError :: new_bound ( 
97+                     py, 
98+                     CStr :: from_bytes_with_nul ( b"utf-32\0 " ) . unwrap ( ) , 
99+                     self . as_bytes ( ) , 
100+                     0 ..self . as_bytes ( ) . len ( ) , 
101+                     CStr :: from_bytes_with_nul ( b"error converting utf-32\0 " ) . unwrap ( ) , 
102+                 ) ?
103+                 . into ( ) ) , 
110104            } , 
111105        } 
112106    } 
0 commit comments