File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -938,8 +938,10 @@ mod array {
938938 /* XXX Make the block size settable */
939939 const BLOCKSIZE : usize = 64 * 1024 ;
940940
941- let bytes = self . read ( ) ;
942- let bytes = bytes. get_bytes ( ) ;
941+ let bytes = {
942+ let bytes = self . read ( ) ;
943+ bytes. get_bytes ( ) . to_vec ( )
944+ } ;
943945
944946 for b in bytes. chunks ( BLOCKSIZE ) {
945947 let b = PyBytes :: from ( b. to_vec ( ) ) . into_ref ( & vm. ctx ) ;
Original file line number Diff line number Diff line change @@ -126,3 +126,20 @@ def test_array_frombytes():
126126a = array ("B" , [0 ])
127127assert a .__contains__ (0 )
128128assert not a .__contains__ (1 )
129+
130+
131+ class _ReenteringWriter :
132+ def __init__ (self , arr ):
133+ self .arr = arr
134+ self .reentered = False
135+
136+ def write (self , chunk ):
137+ if not self .reentered :
138+ self .reentered = True
139+ self .arr .append (0 )
140+ return len (chunk )
141+
142+
143+ arr = array ("b" , range (128 ))
144+ arr .tofile (_ReenteringWriter (arr ))
145+ assert len (arr ) == 129
You can’t perform that action at this time.
0 commit comments