Skip to content

Restore IndexError for oversized empty slice writes - #1528

Merged
jswhit merged 1 commit into
Unidata:masterfrom
zack-dev-cm:fix/empty-slice-write-indexerror
Nov 21, 2026
Merged

jswhit merged 1 commit into
Unidata:masterfrom
zack-dev-cm:fix/empty-slice-write-indexerror

Conversation

@zack-dev-cm

Copy link
Copy Markdown
Contributor

Fixes #1527.

With two records in an unlimited dimension, variable[-3:] = [9, 8, 7] raised a slice-size IndexError before #1499. The empty-write shape check now raises a NumPy ValueError, which affects the exception check in h5netcdf/h5netcdf#341.

Restore the slice-size IndexError for oversized writes through empty one-dimensional slices. Single values still broadcast to an empty selection. Fancy indexing, multidimensional broadcasting, and valid unlimited-dimension growth retain their existing behavior.

The regression covers fixed and unlimited dimensions, including an ellipsis and a wrapped slice. It checks the dimension length and stored values after both the rejected write and a valid empty write.

Validated a rebuilt Linux wheel with Python 3.12, NumPy 2.3.5, netCDF-C 4.9.2, and HDF5 1.10.10. All 15 direct assignment cases and the 14 targeted tests from h5netcdf/h5netcdf#341 passed.

AI-assisted investigation and patch.

Signed-off-by: Zakhar Pashkin <112114097+zack-dev-cm@users.noreply.github.com>
@jswhit
jswhit merged commit ee4c242 into Unidata:master Nov 21, 2026
41 of 43 checks passed
@jswhit

jswhit commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

thanks @zack-dev-cm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative slice assignment raises ValueError instead of IndexError since 1.7.5

2 participants