Remove use of simplejson throughout code base (#43548)

* Remove use of simplejson throughout code base. Fixes #42761

* Address failing tests

* Remove simplejson from contrib and other outlying files

* Add changelog fragment for simplejson removal
This commit is contained in:
Matt Martz 2018-08-10 11:13:29 -05:00 committed by GitHub
commit c1c229c6d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 73 additions and 285 deletions

View file

@ -497,6 +497,7 @@ EXAMPLES = '''
'''
import datetime
import json
import os
import platform
import socket
@ -508,28 +509,6 @@ from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.urls import open_url
HAS_LIB_JSON = True
try:
import json
# Detect the python-json library which is incompatible
# Look for simplejson if that's the case
try:
if (
not isinstance(json.loads, types.FunctionType) or
not isinstance(json.dumps, types.FunctionType)
):
raise ImportError
except AttributeError:
raise ImportError
except ImportError:
try:
import simplejson as json
except ImportError:
HAS_LIB_JSON = False
except SyntaxError:
HAS_LIB_JSON = False
class LogicMonitor(object):
def __init__(self, module, **params):
@ -2148,9 +2127,6 @@ def main():
supports_check_mode=True
)
if HAS_LIB_JSON is not True:
module.fail_json(msg="Unable to load JSON library")
selector(module)

View file

@ -113,30 +113,10 @@ RETURN = '''
...
'''
import json
import socket
import types
HAS_LIB_JSON = True
try:
import json
# Detect the python-json library which is incompatible
# Look for simplejson if that's the case
try:
if (
not isinstance(json.loads, types.FunctionType) or
not isinstance(json.dumps, types.FunctionType)
):
raise ImportError
except AttributeError:
raise ImportError
except ImportError:
try:
import simplejson as json
except ImportError:
HAS_LIB_JSON = False
except SyntaxError:
HAS_LIB_JSON = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils._text import to_native
@ -577,9 +557,6 @@ def main():
supports_check_mode=True
)
if HAS_LIB_JSON is not True:
module.fail_json(msg="Unable to load JSON library")
selector(module)

View file

@ -95,11 +95,7 @@ EXAMPLES = '''
RETURN = '''
'''
try:
import json
except ImportError:
import simplejson as json
import json
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url

View file

@ -64,6 +64,8 @@ EXAMPLES = '''
- name: unsubscribe from common checks
sensu_subscription: name=common state=absent
'''
import json
import traceback
from ansible.module_utils.basic import AnsibleModule
@ -74,11 +76,6 @@ def sensu_subscription(module, path, name, state='present', backup=False):
changed = False
reasons = []
try:
import json
except ImportError:
import simplejson as json
try:
config = json.load(open(path))
except IOError as e: