Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,13 @@ def open(cls, filename, mode='r', format='NETCDF4', group=None,
if (len(filename) == 88 and
LooseVersion(nc4.__version__) < "1.3.1"):
warnings.warn(
'\nA segmentation fault may occur when the\n'
'file path has exactly 88 characters as it does\n'
'in this case. The issue is known to occur with\n'
'version 1.2.4 of netCDF4 and can be addressed by\n'
'upgrading netCDF4 to at least version 1.3.1.\n'
'More details can be found here:\n'
'https://github.com/pydata/xarray/issues/1745 \n')
'A segmentation fault may occur when the '
'file path has exactly 88 characters as it does '
'in this case. The issue is known to occur with '
'version 1.2.4 of netCDF4 and can be addressed by '
'upgrading netCDF4 to at least version 1.3.1. '
'More details can be found here: '
'https://github.com/pydata/xarray/issues/1745')
if format is None:
format = 'NETCDF4'
opener = functools.partial(_open_netcdf4_group, filename, mode=mode,
Expand Down
6 changes: 4 additions & 2 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,10 @@ def test_88_character_filename_segmentation_fault(self):
# should be fixed in netcdf4 v1.3.1
with mock.patch('netCDF4.__version__', '1.2.4'):
with warnings.catch_warnings():
warnings.simplefilter("error")
with raises_regex(Warning, 'segmentation fault'):
message = ('A segmentation fault may occur when the '
'file path has exactly 88 characters')
warnings.filterwarnings('error', message)
with pytest.raises(Warning):
# Need to construct 88 character filepath
xr.Dataset().to_netcdf('a' * (88 - len(os.getcwd()) - 1))

Expand Down