Skip to content

Commit

Permalink
src/sage/combinat/words/alphabet.py: Check type before calling len
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Oct 11, 2023
1 parent d0ab75c commit 8632f17
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/sage/combinat/words/alphabet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@
# http://www.gnu.org/licenses/
# ****************************************************************************

from sage.categories.sets_cat import Sets
import collections.abc

from sage.sets.totally_ordered_finite_set import TotallyOrderedFiniteSet
from sage.sets.family import Family

from sage.rings.integer import Integer
from sage.categories.sets_cat import Sets
from sage.rings.infinity import Infinity

from sage.rings.integer import Integer
from sage.sets.family import Family
from sage.sets.non_negative_integers import NonNegativeIntegers
from sage.sets.totally_ordered_finite_set import TotallyOrderedFiniteSet


set_of_letters = {
Expand Down Expand Up @@ -222,7 +221,7 @@ def build_alphabet(data=None, names=None, name=None):
return IntegerRange(Integer(data))
if isinstance(names, str):
return TotallyOrderedFiniteSet([names + '%d' % i for i in range(data)])
if len(names) == data:
if isinstance(names, collections.abc.Sequence) and len(names) == data:
return TotallyOrderedFiniteSet(names)
raise ValueError("invalid value for names")

Expand Down

0 comments on commit 8632f17

Please sign in to comment.