diff --git a/awx/api/parsers.py b/awx/api/parsers.py index eadeaf0c97..468962976c 100644 --- a/awx/api/parsers.py +++ b/awx/api/parsers.py @@ -62,9 +62,4 @@ class JSONParser(parsers.JSONParser): raise ParseError(_('JSON parse error - not a JSON object')) return obj except ValueError as exc: - try: - # PyYAML can also parse JSON-style input string, and support more flexible - # input grammar like trailing commas. - return yaml.load(data, OrderedDictLoader) - except Exception: - raise ParseError(_('JSON parse error - %s') % six.text_type(exc)) + raise ParseError(_('JSON parse error - %s\nPossible cause: trailing comma.' % six.text_type(exc))) diff --git a/awx/main/tests/unit/api/test_parsers.py b/awx/main/tests/unit/api/test_parsers.py deleted file mode 100644 index 3740e23f87..0000000000 --- a/awx/main/tests/unit/api/test_parsers.py +++ /dev/null @@ -1,31 +0,0 @@ -import pytest - -import StringIO -from collections import OrderedDict - -from awx.api.parsers import JSONParser - - -@pytest.mark.parametrize('input_, output', [ - ('{"foo": "bar", "alice": "bob"}', OrderedDict([("foo", "bar"), ("alice", "bob")])), - ('{"foo": "bar", "alice": "bob",\n }', OrderedDict([("foo", "bar"), ("alice", "bob")])), - ('{"foo": ["alice", "bob"]}', {"foo": ["alice","bob"]}), - ('{"foo": ["alice", "bob",\n ]}', {"foo": ["alice","bob"]}), - ('{"foo": "\\"bar, \\n}"}', {"foo": "\"bar, \n}"}), - ('{"foo": ["\\"alice,\\n ]", "bob"]}', {"foo": ["\"alice,\n ]","bob"]}), -]) -def test_trailing_comma_support(input_, output): - input_buffer = StringIO.StringIO() - input_buffer.write(input_) - input_buffer.seek(0) - assert JSONParser().parse(input_buffer) == output - input_buffer.close() - - -def test_yaml_load_preserves_input_order(): - input_ = '{"a": "b", "c": "d", "e": "f"}' - output = ('a', 'c', 'e') - input_buffer = StringIO.StringIO() - input_buffer.write(input_) - input_buffer.seek(0) - assert tuple(JSONParser().parse(input_buffer)) == output