Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Enhancements

Bug fixes
~~~~~~~~~
- Added warning in api.py of a netCDF4 bug that occurs when
the filepath has 88 characters (:issue:`1745`).
By `Liam Brannigan <https://github.com/braaannigan>` _.
- Fixed encoding of multi-dimensional coordinates in
:py:meth:`~Dataset.to_netcdf` (:issue:`1763`).
By `Mike Neish <https://github.com/neishm>`_.
Expand Down
10 changes: 9 additions & 1 deletion xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from glob import glob
from io import BytesIO
from numbers import Number

import warnings

import numpy as np

Expand Down Expand Up @@ -281,6 +281,14 @@ def maybe_decode_store(store, lock=False):
engine = _get_default_engine(filename_or_obj,
allow_remote=True)
if engine == 'netcdf4':
import netCDF4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you accidentally kept your changes in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that I had checked out the original version again to replace all of my edits, but that doesn't seem to have worked. I'm looking for a solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simply revert this file (e.g., copy/paste from master) and then add another commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried that would cause some new unforeseen problem. I've commited this now.

if len( filename_or_obj ) == 88 and float(netCDF4.__version__[:3]) < 1.3:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove spaces around filename_or_obj, per pep8.

warnings.warn('\nA segmentation fault may occur when the \n'
'file path has exactly 88 characters. The issue is known \n'
'to occur with version 1.2.4 of netCDF4 and can be \n'
'addressed by 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')
store = backends.NetCDF4DataStore.open(filename_or_obj,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this inside NetCDF4DataStore.open() instead? We try to keep the backend specific logic in the backend classes.

group=group,
autoclose=autoclose)
Expand Down