From 8d345c7cd6a7b3331510fc7b90d2e9795db1d1e8 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 1 Jun 2018 14:24:57 -0400 Subject: [PATCH] Do not try to import simplejson in jsonfile.py (#40983) With the addition on ajson.py in cbb6a7f4e831abd2d56375fb0aa22465e0cc7c0c, two new classes were created: AnsibleJSONDecoder and AnsibleJSONEncoder. These classes are used when calling json.looads() and json.dumps(). This works fine with everything except the jsonfile.py cache plugin, which would first try to import simplejson as json, then fall back to json. When simplejson is installed, the load() or dump methods from simplejson are called, which then try to use the AnsibleJSONEncoder/AnsibleJSONDecoder subclass from ajson.py. But asjon.py imports json, not simplejson, and things blow up. (cherry picked from commit 479b26fe31d5eff5e7e6a4504aa174591414a8be) --- lib/ansible/plugins/cache/jsonfile.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index bd19120903..4319b88fd6 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -43,11 +43,7 @@ DOCUMENTATION = ''' ''' import codecs - -try: - import simplejson as json -except ImportError: - import json +import json from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder from ansible.plugins.cache import BaseFileCacheModule