diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 317c935995b..a9e8feb905c 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -61,6 +61,8 @@ New Features variables of a section at once, and shows the expanded attributes and data more compactly and indented below their variable (:pull:`11284`). By `Michael Niklas `_. +- Use ``check_string_dtype()`` to detect variable-length strings in h5netcdf backend (:pull:`11789`). + By `Kai Mühlbauer `_. Breaking Changes diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py index d2060976d01..18ade782764 100644 --- a/xarray/backends/h5netcdf_.py +++ b/xarray/backends/h5netcdf_.py @@ -297,8 +297,8 @@ def open_store_variable(self, name, var): }, ) else: - vlen_dtype = h5py.check_dtype(vlen=var.dtype) - if vlen_dtype is str: + string_info = h5py.check_string_dtype(var.dtype) + if string_info is not None and string_info.length is None: encoding["dtype"] = str else: # xarray doesn't support writing arbitrary vlen dtypes yet, so