diff options
author | Yuchen Xie <yuchen.xie@live.com> | 2018-06-26 06:20:53 +0800 |
---|---|---|
committer | Jie Luo <anandolee@gmail.com> | 2018-06-25 15:20:53 -0700 |
commit | 595231dd5cc92c3ac64faa39f22707b5ec58731a (patch) | |
tree | 815fdbda53551ae7373845f053848451ea8310be | |
parent | d65d5821bc76a5e43bfac0a227d970f5bc88b789 (diff) |
Update minimal Python version to 2.7 (#4207)
-rw-r--r-- | python/README.md | 2 | ||||
-rw-r--r-- | python/google/protobuf/internal/json_format_test.py | 3 | ||||
-rw-r--r-- | python/google/protobuf/json_format.py | 6 | ||||
-rwxr-xr-x | python/setup.py | 7 |
4 files changed, 5 insertions, 13 deletions
diff --git a/python/README.md b/python/README.md index 4c194297..4b48225a 100644 --- a/python/README.md +++ b/python/README.md @@ -30,7 +30,7 @@ join the Protocol Buffers discussion list and let us know! Installation ============ -1) Make sure you have Python 2.6 or newer. If in doubt, run: +1) Make sure you have Python 2.7 or newer. If in doubt, run: $ python -V 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) diff --git a/python/setup.py b/python/setup.py index 1a282f99..ebbe1bb6 100755 --- a/python/setup.py +++ b/python/setup.py @@ -149,10 +149,9 @@ class build_py(_build_py): class test_conformance(_build_py): target = 'test_python' def run(self): - if sys.version_info >= (2, 7): - # Python 2.6 dodges these extra failures. - os.environ["CONFORMANCE_PYTHON_EXTRA_FAILURES"] = ( - "--failure_list failure_list_python-post26.txt") + # Python 2.6 dodges these extra failures. + os.environ["CONFORMANCE_PYTHON_EXTRA_FAILURES"] = ( + "--failure_list failure_list_python-post26.txt") cmd = 'cd ../conformance && make %s' % (test_conformance.target) status = subprocess.check_call(cmd, shell=True) |