Revert "load now does not modify the incomming data"

This reverts commit 2126e9fee1.
we judge this to be too big a change for stable, keeping in devel
we may still add part or all back to stable in the future.
pull/14290/head
Brian Coca 9 years ago
parent 2126e9fee1
commit 5035e53e80

@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import copy
import json
import os
import stat
import subprocess
@ -73,17 +74,23 @@ class DataLoader():
a JSON or YAML string.
'''
# YAML parser will take JSON as it is a subset.
try:
# we first try to load this data as JSON
return json.loads(data)
except:
# if loading JSON failed for any reason, we go ahead
# and try to parse it as YAML instead
if isinstance(data, AnsibleUnicode):
# The PyYAML's libyaml bindings use PyUnicode_CheckExact so
# they are unable to cope with our subclass.
# Unwrap and re-wrap the unicode so we can keep track of line
# numbers
in_data = text_type(data)
new_data = text_type(data)
else:
in_data = data
new_data = data
try:
new_data = self._safe_load(in_data, file_name=file_name)
new_data = self._safe_load(new_data, file_name=file_name)
except YAMLError as yaml_exc:
self._handle_error(yaml_exc, file_name, show_content)

Loading…
Cancel
Save