From 4794b5da4591797eb250d3e983f43b4ab0b75528 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 7 Nov 2016 20:47:46 -0600 Subject: [PATCH] Merge class dict with parent dict when creating meta attributes In some situations, where the Base class defines an Attribute, the BaseMeta class doesn't properly see the _get_parent_attribute or _get_attr_ 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 --- lib/ansible/playbook/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 652fbdca251..331ee53bd68 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()