summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2016-11-07 20:47:46 -0600
committerJames Cammarata <jimi@sngx.net>2016-11-07 20:47:46 -0600
commit256aaaff7e5080c23da1ca00ee60ede177c594a4 (patch)
treecb26622b29601597a5e2f98f184da3c379437f04
parent912d6ed8cc261ac02fc514c89e04b3f48a7e6d68 (diff)
downloadansible-issue_18378_handler_environment_inheritance_alt.tar.gz
Merge class dict with parent dict when creating meta attributesissue_18378_handler_environment_inheritance_alt
In some situations, where the Base class defines an Attribute, the BaseMeta class doesn't properly see the _get_parent_attribute or _get_attr_<whatever> methods because of multiple layers of subclasses (ie. Handler, which subclasses Task). This addresses that by merging the __dict__ of the parent with the current classes __dict__ meaning all future iterations see available special methods. Fixes #18378
-rw-r--r--lib/ansible/playbook/base.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py
index 652fbdca25..331ee53bd6 100644
--- a/lib/ansible/playbook/base.py
+++ b/lib/ansible/playbook/base.py
@@ -131,7 +131,9 @@ class BaseMeta(type):
for parent in parents:
if hasattr(parent, '__dict__'):
_create_attrs(parent.__dict__, dst_dict)
- _process_parents(parent.__bases__, dst_dict)
+ new_dst_dict = parent.__dict__.copy()
+ new_dst_dict.update(dst_dict)
+ _process_parents(parent.__bases__, new_dst_dict)
# create some additional class attributes
dct['_attributes'] = dict()