mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Use itertools instead of set for tags, as the data may not hash well
The tags field may contain bad data before it is post_validated, however some methods assumed it would be a simple list or string. Using itertools gets us around the problem of the data potentially not being hashable Fixes #9380
This commit is contained in:
parent
af49944ab2
commit
0eb1c880dd
2 changed files with 9 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import itertools
|
||||
import uuid
|
||||
|
||||
from functools import partial
|
||||
|
@ -232,6 +233,10 @@ class Base:
|
|||
new_me._loader = self._loader
|
||||
new_me._variable_manager = self._variable_manager
|
||||
|
||||
# if the ds value was set on the object, copy it to the new copy too
|
||||
if hasattr(self, '_ds'):
|
||||
new_me._ds = self._ds
|
||||
|
||||
return new_me
|
||||
|
||||
def post_validate(self, templar):
|
||||
|
@ -340,7 +345,8 @@ class Base:
|
|||
if not isinstance(new_value, list):
|
||||
new_value = [ new_value ]
|
||||
|
||||
return list(set(value + new_value))
|
||||
#return list(set(value + new_value))
|
||||
return [i for i,_ in itertools.groupby(value + new_value)]
|
||||
|
||||
def __getstate__(self):
|
||||
return self.serialize()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import itertools
|
||||
from six import string_types
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
|
@ -67,7 +68,7 @@ class Taggable:
|
|||
else:
|
||||
tags = set([tags])
|
||||
else:
|
||||
tags = set(tags)
|
||||
tags = [i for i,_ in itertools.groupby(tags)]
|
||||
else:
|
||||
# this makes intersection work for untagged
|
||||
tags = self.__class__.untagged
|
||||
|
|
Loading…
Reference in a new issue