File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,9 @@ def fileno(self):
209209 def read (self , * args , ** kwargs ):
210210 return self .fobj .read (* args , ** kwargs )
211211
212+ def readinto (self , * args , ** kwargs ):
213+ return self .fobj .readinto (* args , ** kwargs )
214+
212215 def write (self , * args , ** kwargs ):
213216 return self .fobj .write (* args , ** kwargs )
214217
Original file line number Diff line number Diff line change @@ -557,10 +557,10 @@ def _read_header(fileobj):
557557
558558 with Opener (fileobj ) as f :
559559
560- # Read the header in one block .
561- header_str = f . read (header_2_dtype .itemsize )
562- header_rec = np . frombuffer ( buffer = bytearray ( header_str ),
563- dtype = header_2_dtype )
560+ # Read the header into a bytearray .
561+ header_buf = bytearray (header_2_dtype .itemsize )
562+ n_read = f . readinto ( header_buf )
563+ header_rec = np . frombuffer ( buffer = header_buf , dtype = header_2_dtype )
564564 # Check endianness
565565 endianness = native_code
566566 if header_rec ['hdr_size' ] != TrkFile .HEADER_SIZE :
You can’t perform that action at this time.
0 commit comments