#8617·datasets

`SplitDict.copy()` crashes when `dataset_name` is not set

Author: betacatslingCreated Sep 14, 2026Updated Sep 14, 2026

Description

SplitDict.copy() (and SplitDict.from_split_dict) crashes with AttributeError: 'SplitInfo' object has no attribute 'get' whenever the split dict contains SplitInfo objects and dataset_name is None.

Reproduction

from datasets import SplitDict, SplitInfo

split_dict = SplitDict({"train": SplitInfo(name="train", num_bytes=1337, num_examples=42)})
split_dict.copy()

Traceback:

File ".../datasets/splits.py", line 574, in from_split_dict
    dataset_name = split_infos[0].get("dataset_name") if split_infos else None
AttributeError: 'SplitInfo' object has no attribute 'get'

Expected behavior

copy() should work for SplitDict instances holding SplitInfo objects, which is the normal state after construction (e.g. from a dataset's info). The method should read dataset_name from SplitInfo.dataset_name when the entries are SplitInfo objects, and only fall back to .get() for raw dictionaries.

Environment

  • datasets version: 5.0.2.dev0 (main, d336dcb)
  • Python: 3.11