mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 04:21:17 +00:00
utils/types: toggle_set: TypeError on string
Strings are iterable, so can be used to instantiate sets (resulting in a set of chars). This is never what we want for toggle_set's though, and may result in difficult-to-interpret errors when parsing configuration, so raise a TypeError if attempting to create a toggle_set with a string.
This commit is contained in:
parent
7464010677
commit
67ea7c8ee1
@ -381,6 +381,14 @@ class toggle_set(set):
|
||||
dest.add(item)
|
||||
return dest
|
||||
|
||||
def __init__(self, *args):
|
||||
if args:
|
||||
value = args[0]
|
||||
if isinstance(value, basestring):
|
||||
msg = 'invalid type for toggle_set: "{}"'
|
||||
raise TypeError(msg.format(type(value)))
|
||||
set.__init__(self, *args)
|
||||
|
||||
def merge_with(self, other):
|
||||
new_self = copy(self)
|
||||
return toggle_set.merge(other, new_self)
|
||||
|
Loading…
x
Reference in New Issue
Block a user