Skip to content

Commit bd10d2f

Browse files
authored
Accessing the Exception message via e.args[0] (#6451)
When opening gz files, in the case of the TypeError exception, another exception would be raised: AttributeError: 'TypeError' object has no attribute 'message' As python 3 exceptions have no attribute message, I replace it for e.args[0] following the pattern a few lines below.
1 parent b112aa2 commit bd10d2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

xarray/backends/scipy_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ def _open_scipy_netcdf(filename, mode, mmap, version):
8686
)
8787
except TypeError as e:
8888
# TODO: gzipped loading only works with NetCDF3 files.
89-
if "is not a valid NetCDF 3 file" in e.message:
89+
errmsg = e.args[0]
90+
if "is not a valid NetCDF 3 file" in errmsg:
9091
raise ValueError("gzipped file loading only supports NetCDF 3 files.")
9192
else:
9293
raise

0 commit comments

Comments
 (0)