diff options
Diffstat (limited to 'python/google')
-rw-r--r-- | python/google/protobuf/internal/json_format_test.py | 3 | ||||
-rw-r--r-- | python/google/protobuf/json_format.py | 6 |
2 files changed, 1 insertions, 8 deletions
diff --git a/python/google/protobuf/internal/json_format_test.py b/python/google/protobuf/internal/json_format_test.py index d891dce1..7f649406 100644 --- a/python/google/protobuf/internal/json_format_test.py +++ b/python/google/protobuf/internal/json_format_test.py @@ -791,9 +791,6 @@ class JsonFormatTest(JsonFormatBase): json_format.Parse(text, parsed_message, ignore_unknown_fields=True) def testDuplicateField(self): - # Duplicate key check is not supported for python2.6 - if sys.version_info < (2, 7): - return self.CheckError('{"int32Value": 1,\n"int32Value":2}', 'Failed to load JSON: duplicate key int32Value.') diff --git a/python/google/protobuf/json_format.py b/python/google/protobuf/json_format.py index 8d338d3e..58c94a47 100644 --- a/python/google/protobuf/json_format.py +++ b/python/google/protobuf/json_format.py @@ -396,11 +396,7 @@ def Parse(text, message, ignore_unknown_fields=False): """ if not isinstance(text, six.text_type): text = text.decode('utf-8') try: - if sys.version_info < (2, 7): - # object_pair_hook is not supported before python2.7 - js = json.loads(text) - else: - js = json.loads(text, object_pairs_hook=_DuplicateChecker) + js = json.loads(text, object_pairs_hook=_DuplicateChecker) except ValueError as e: raise ParseError('Failed to load JSON: {0}.'.format(str(e))) return ParseDict(js, message, ignore_unknown_fields) |