File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,8 +49,11 @@ impl ZBytes {
4949 }
5050 }
5151
52- fn to_bytes ( & self ) -> Cow < [ u8 ] > {
53- self . 0 . to_bytes ( )
52+ fn to_bytes < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyBytes > > {
53+ // Not using `ZBytes::to_bytes`
54+ PyBytes :: new_bound_with ( py, self . 0 . len ( ) , |bytes| {
55+ self . 0 . reader ( ) . read_exact ( bytes) . into_pyres ( )
56+ } )
5457 }
5558
5659 fn to_string ( & self ) -> PyResult < Cow < str > > {
@@ -68,9 +71,11 @@ impl ZBytes {
6871 }
6972
7073 fn __bytes__ < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyBytes > > {
71- PyBytes :: new_bound_with ( py, self . 0 . len ( ) , |bytes| {
72- self . 0 . reader ( ) . read_exact ( bytes) . into_pyres ( )
73- } )
74+ self . to_bytes ( py)
75+ }
76+
77+ fn __str__ ( & self ) -> PyResult < Cow < str > > {
78+ self . to_string ( )
7479 }
7580
7681 fn __eq__ ( & self , other : & Bound < PyAny > ) -> PyResult < bool > {
You can’t perform that action at this time.
0 commit comments