1- use crate :: ffi_ptr_ext:: FfiPtrExt ;
2- use crate :: py_result_ext:: PyResultExt ;
31use crate :: types:: PyBytes ;
4- use crate :: { ffi, Bound , IntoPyObject , PyErr , PyResult , Python } ;
52#[ cfg( not( Py_LIMITED_API ) ) ]
6- use pyo3_ffi:: compat:: {
7- PyBytesWriter_Create , PyBytesWriter_Discard , PyBytesWriter_Finish , PyBytesWriter_GetData ,
8- PyBytesWriter_GetSize , PyBytesWriter_Grow , PyBytesWriter_WriteBytes ,
9- _PyBytesWriter_GetAllocated,
3+ use crate :: {
4+ ffi:: {
5+ self ,
6+ compat:: {
7+ PyBytesWriter_Create , PyBytesWriter_Discard , PyBytesWriter_Finish ,
8+ PyBytesWriter_GetData , PyBytesWriter_GetSize , PyBytesWriter_Grow ,
9+ PyBytesWriter_WriteBytes , _PyBytesWriter_GetAllocated,
10+ } ,
11+ } ,
12+ ffi_ptr_ext:: FfiPtrExt ,
13+ py_result_ext:: PyResultExt ,
1014} ;
15+ use crate :: { Bound , IntoPyObject , PyErr , PyResult , Python } ;
1116use std:: io:: IoSlice ;
1217#[ cfg( not( Py_LIMITED_API ) ) ]
1318use std:: ptr:: { self , NonNull } ;
@@ -95,7 +100,7 @@ impl<'py> TryFrom<PyBytesWriter<'py>> for Bound<'py, PyBytes> {
95100impl < ' py > From < PyBytesWriter < ' py > > for Bound < ' py , PyBytes > {
96101 #[ inline]
97102 fn from ( writer : PyBytesWriter < ' py > ) -> Self {
98- Ok ( PyBytes :: new ( & writer. buffer ) )
103+ PyBytes :: new ( writer . python , & writer. buffer )
99104 }
100105}
101106
@@ -186,7 +191,7 @@ impl std::io::Write for PyBytesWriter<'_> {
186191 }
187192
188193 #[ inline]
189- fn write_fmt ( & mut self , args : Arguments < ' _ > ) -> std:: io:: Result < ( ) > {
194+ fn write_fmt ( & mut self , args : std :: fmt :: Arguments < ' _ > ) -> std:: io:: Result < ( ) > {
190195 self . buffer . write_fmt ( args)
191196 }
192197}
@@ -199,7 +204,7 @@ mod tests {
199204 #[ test]
200205 fn test_io_write ( ) {
201206 Python :: attach ( |py| {
202- let buf: [ u8 ; _ ] = [ 1 , 2 , 3 , 4 ] ;
207+ let buf = [ 1 , 2 , 3 , 4 ] ;
203208 let mut writer = PyBytesWriter :: new ( py) . unwrap ( ) ;
204209 writer. write ( & buf) . unwrap ( ) ;
205210 let bytes: Bound < ' _ , PyBytes > = writer. try_into ( ) . unwrap ( ) ;
0 commit comments