@@ -91,10 +91,10 @@ def is_correct_format(cls, fileobj):
9191 otherwise returns False.
9292 """
9393 with Opener (fileobj ) as f :
94- magic_number = asstr ( f . fobj . read (len (cls .MAGIC_NUMBER ) ))
94+ magic_number = f . read (len (cls .MAGIC_NUMBER ))
9595 f .seek (- len (cls .MAGIC_NUMBER ), os .SEEK_CUR )
9696
97- return magic_number . strip ( ) == cls .MAGIC_NUMBER
97+ return asstr ( magic_number ) == cls .MAGIC_NUMBER
9898
9999 @classmethod
100100 def create_empty_header (cls ):
@@ -312,25 +312,25 @@ def _read_header(cls, fileobj):
312312 with Opener (fileobj ) as f :
313313
314314 # Record start position
315- start_position = f .fobj . tell ()
315+ start_position = f .tell ()
316316
317317 # Make sure we are at the beginning of the file
318- f .fobj . seek (0 , os .SEEK_SET )
318+ f .seek (0 , os .SEEK_SET )
319319
320320 # Read magic number
321- magic_number = asstr ( f . fobj . read (len (cls .MAGIC_NUMBER ) ))
321+ magic_number = f . read (len (cls .MAGIC_NUMBER ))
322322
323- if magic_number != cls .MAGIC_NUMBER :
323+ if asstr ( magic_number ) != cls .MAGIC_NUMBER :
324324 raise HeaderError (f"Invalid magic number: { magic_number } " )
325325
326326 hdr [Field .MAGIC_NUMBER ] = magic_number
327327
328- f .fobj . seek (1 , os .SEEK_CUR ) # Skip \n
328+ f .seek (1 , os .SEEK_CUR ) # Skip \n
329329
330330 found_end = False
331331
332332 # Read all key-value pairs contained in the header, stop at EOF
333- for n_line , line in enumerate (f . fobj , 1 ):
333+ for n_line , line in enumerate (f , 1 ):
334334 line = asstr (line ).strip ()
335335
336336 if not line : # Skip empty lines
@@ -353,7 +353,7 @@ def _read_header(cls, fileobj):
353353
354354 # Set the file position where it was, in case it was previously open
355355 if start_position is not None :
356- f .fobj . seek (start_position , os .SEEK_SET )
356+ f .seek (start_position , os .SEEK_SET )
357357
358358 # Check integrity of TCK header.
359359 if 'datatype' not in hdr :
0 commit comments