diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 6bfdf0b6f0a..c4c9097ab0a 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -37,6 +37,8 @@ Bug fixes - Fix :py:meth:`xr.polyval` with non-system standard integer coeffs (:pull:`7619`). By `Shreyal Gupta `_ and `Michael Niklas `_. +- Improve error message when trying to open a file which you do not have permission to read (:issue:`6523`, :pull:`7629`). + By `Thomas Coleman `_. Documentation ~~~~~~~~~~~~~ diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index bae1dcd2225..d6ad6dfbe18 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -135,6 +135,8 @@ def guess_engine( try: if backend.guess_can_open(store_spec): return engine + except PermissionError: + raise except Exception: warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)