mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 15:12:25 +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:
		
				
					committed by
					
						 Marc Bonnici
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							7464010677
						
					
				
				
					commit
					67ea7c8ee1
				
			| @@ -381,6 +381,14 @@ class toggle_set(set): | |||||||
|                 dest.add(item) |                 dest.add(item) | ||||||
|         return dest |         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): |     def merge_with(self, other): | ||||||
|         new_self = copy(self) |         new_self = copy(self) | ||||||
|         return toggle_set.merge(other, new_self) |         return toggle_set.merge(other, new_self) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user