diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 6e9045c1c7f..d5799a78f91 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -104,11 +104,6 @@ def list_engines(): def guess_engine(store_spec): engines = list_engines() - # use the pre-defined selection order for netCDF files - for engine in ["netcdf4", "h5netcdf", "scipy"]: - if engine in engines and engines[engine].guess_can_open(store_spec): - return engine - for engine, backend in engines.items(): try: if backend.guess_can_open and backend.guess_can_open(store_spec): diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 1eff91e3608..e76db3c8501 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -636,6 +636,7 @@ def read_magic_number(filename_or_obj, count=8): elif isinstance(filename_or_obj, io.IOBase): if filename_or_obj.tell() != 0: raise ValueError( + "cannot guess the engine, " "file-like object read/write pointer not at the start of the file, " "please close and reopen, or use a context manager" ) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 2d20f7f63b3..3750c0715ae 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2661,7 +2661,7 @@ def test_open_fileobj(self): open_dataset(f, engine="scipy") f.seek(8) - with raises_regex(ValueError, "read/write pointer not at the start"): + with raises_regex(ValueError, "cannot guess the engine"): open_dataset(f)