Merge pull request #6679 from renard/fix-simplejson-module

Fix TypeError when using old simplejson lib.
pull/6666/merge
Michael DeHaan 11 years ago
commit 9be732d8f2

@ -884,6 +884,9 @@ class AnsibleModule(object):
for encoding in ("utf-8", "latin-1", "unicode_escape"):
try:
return json.dumps(data, encoding=encoding)
# Old systems using simplejson module does not support encoding keyword.
except TypeError, e:
return json.dumps(data)
except UnicodeDecodeError, e:
continue
self.fail_json(msg='Invalid unicode encoding encountered')

Loading…
Cancel
Save