From 2dc4b4ba20c91b49fe328912ad4013ec00bdd0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Thu, 22 Oct 2026 14:15:41 +0200 Subject: [PATCH 1/2] Use h5py.check_string_dtype instead of deprecated h5py.check_dtype --- xarray/backends/h5netcdf_.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 4a4211cfac8d462b7381207c60de8ca06dfeb101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Thu, 22 Oct 2026 14:23:01 +0200 Subject: [PATCH 2/2] Add whats-new.rst entry --- doc/whats-new.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 3abeff78a77..3742fddcee3 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -51,6 +51,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