mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 23:31:25 -07:00
Do not use mutable defaults in FieldAttribute, instead allow supplying a callable for defaults of mutable types. Fixes #46824 (#46833)
This commit is contained in:
parent
0dd17b521f
commit
a06a5ded61
14 changed files with 57 additions and 37 deletions
|
@ -162,6 +162,9 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
|
|||
# need a unique object here (all members contained within are
|
||||
# unique already).
|
||||
self._attributes = self._attributes.copy()
|
||||
for key, value in self._attributes.items():
|
||||
if callable(value):
|
||||
self._attributes[key] = value()
|
||||
|
||||
# and init vars, avoid using defaults in field declaration as it lives across plays
|
||||
self.vars = dict()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue