diff --git a/Lib/fontTools/otlLib/builder.py b/Lib/fontTools/otlLib/builder.py index 7711fa4c5..5d16b83c2 100644 --- a/Lib/fontTools/otlLib/builder.py +++ b/Lib/fontTools/otlLib/builder.py @@ -2575,7 +2575,7 @@ class ClassDefBuilder(object): self.classes_.add(glyphs) for glyph in glyphs: if glyph in self.glyphs_: - raise TypeError(f"Glyph {glyph} already present in class.") + raise ValueError(f"Glyph {glyph} is already present in class.") self.glyphs_[glyph] = glyphs def classes(self): diff --git a/Tests/otlLib/builder_test.py b/Tests/otlLib/builder_test.py index a2c51331d..6bd05615b 100644 --- a/Tests/otlLib/builder_test.py +++ b/Tests/otlLib/builder_test.py @@ -1103,15 +1103,9 @@ class ClassDefBuilderTest(object): def test_add_exception(self): b = builder.ClassDefBuilder(useClass0=True) - b.add({"a", "b", "c", "d"}) - with pytest.raises(TypeError): - b.add({"a"}) - with pytest.raises(TypeError): - b.add({"b"}) - with pytest.raises(TypeError): - b.add({"c"}) - with pytest.raises(TypeError): - b.add({"d"}) + b.add({"a", "b", "c"}) + with pytest.raises(ValueError): + b.add({"a", "d"}) buildStatTable_test_data = [