From 085d7f3dde51f2af517f5922725bde1ee06405d2 Mon Sep 17 00:00:00 2001 From: Ryan Grout Date: Wed, 29 Mar 2023 11:23:46 -0600 Subject: [PATCH] Use read1 instead of read. --- xarray/core/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 08625fe7d95..96bd21f33fb 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -656,10 +656,10 @@ def read_magic_number_from_file(filename_or_obj, count=8) -> bytes: # check byte header to determine file type if isinstance(filename_or_obj, bytes): magic_number = filename_or_obj[:count] - elif isinstance(filename_or_obj, io.IOBase): + elif isinstance(filename_or_obj, io.BufferedIOBase): if filename_or_obj.tell() != 0: filename_or_obj.seek(0) - magic_number = filename_or_obj.read(count) + magic_number = filename_or_obj.read1(count) filename_or_obj.seek(0) else: raise TypeError(f"cannot read the magic number from {type(filename_or_obj)}")