Skip to content

Commit 2d701cf

Browse files
xylarCopilot
andcommitted
Add check for too many colons
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3c019f2 commit 2d701cf

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • conda_package/mpas_tools/viz/mpas_to_xdmf

conda_package/mpas_tools/viz/mpas_to_xdmf/io.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ def _parse_indices(index_string, dim_size):
302302
if ':' in index_string:
303303
# Support slice notation like ':', '0:10', '0:10:2', etc.
304304
parts = index_string.split(':')
305+
# Validate that parts has at most 3 elements
306+
if len(parts) > 3:
307+
raise ValueError(
308+
f"Invalid index string '{index_string}': too many colons. "
309+
'Expected at most two colons.'
310+
)
305311
# Pad parts to length 3 with empty strings if needed
306312
while len(parts) < 3:
307313
parts.append('')

0 commit comments

Comments
 (0)