Using a forward slash in a node names of a DataTree
causes a RecursionError
#9978
Labels
DataTree
causes a RecursionError
#9978
What happened?
When creating an
xarray.DataTree
object, passing the optionalchildren
parameter with/
in a key of the dictionary produces an infinite recursion loop.It appears that a
ValueError: node names cannot contain forward slashes
is raised, but the program then gets stuck in a mutual recursive loop betweenand
This happens before the
ValueError
can be handled by the call toxarray.DataTree
.What did you expect to happen?
Either of the following:
raise ValueError("node names cannot contain forward slashes")
, without the recursion issue./
in the keys of the children parameter produces nested DataTree objects. This was be behaviour inxarray-contrib/datatree
.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
I tested this on the latest
main
branch in a new conda environment, but it appears the issue is present in every version of xarray since the introduction ofDataTree
.Environment
INSTALLED VERSIONS
commit: None
python: 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910]
python-bits: 64
OS: Linux
OS-release: 6.12.9-arch1-1
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.4-development
xarray: 2025.1.1
pandas: 2.2.3
numpy: 2.2.1
scipy: 1.15.1
netCDF4: 1.7.2
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: 1.6.4.post1
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.10.0
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: None
pip: None
conda: None
pytest: 8.3.4
mypy: None
IPython: None
sphinx: None
The text was updated successfully, but these errors were encountered: