From cc3cb0f65e4904775ca4e3eb277a606943e78887 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 3 Mar 2016 18:13:36 -0500 Subject: [PATCH] fix issues with older yaml lib versions also added missing json import and removed unused ones --- lib/ansible/parsing/dataloader.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index a508eacdda..8b37df5af8 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -21,10 +21,9 @@ __metaclass__ = type import copy import os -import stat +import json import subprocess - -from yaml import load, YAMLError +from yaml import YAMLError from ansible.compat.six import text_type, string_types from ansible.errors import AnsibleFileNotFound, AnsibleParserError, AnsibleError @@ -145,7 +144,10 @@ class DataLoader(): try: return loader.get_single_data() finally: - loader.dispose() + try: + loader.dispose() + except AttributeError: + pass # older versions of yaml don't have dispose function, ignore def _get_file_contents(self, file_name): '''