diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 2b992f0249b..11f9ee49ca2 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -645,7 +645,7 @@ def try_read_magic_number_from_path(pathlike, count=8) -> bytes | None: try: with open(path, "rb") as f: return read_magic_number_from_file(f, count) - except (FileNotFoundError, TypeError): + except (FileNotFoundError, IsADirectoryError, TypeError): pass return None