From 28be89f047f80432442be1d6015a3afd6c997a6d Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Wed, 1 Apr 2026 20:56:59 -0700 Subject: [PATCH] [gdsii] make sure iterable is supported --- masque/file/gdsii.py | 1 + masque/test/test_gdsii.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index f589ad8..116fa07 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -637,6 +637,7 @@ def check_valid_names( max_length: Max allowed length """ + names = tuple(names) allowed_chars = set(string.ascii_letters + string.digits + '_?$') bad_chars = [ diff --git a/masque/test/test_gdsii.py b/masque/test/test_gdsii.py index 7ce8c88..7a2f5b1 100644 --- a/masque/test/test_gdsii.py +++ b/masque/test/test_gdsii.py @@ -1,8 +1,10 @@ from pathlib import Path from typing import cast import numpy +import pytest from numpy.testing import assert_equal, assert_allclose +from ..error import LibraryError from ..pattern import Pattern from ..library import Library from ..file import gdsii @@ -69,3 +71,10 @@ def test_gdsii_annotations(tmp_path: Path) -> None: read_ann = read_lib["cell"].shapes[(1, 0)][0].annotations assert read_ann is not None assert read_ann["1"] == ["hello"] + + +def test_gdsii_check_valid_names_validates_generator_lengths() -> None: + names = (name for name in ("a" * 40,)) + + with pytest.raises(LibraryError, match="invalid names"): + gdsii.check_valid_names(names)