From a04eb8c191e60171a9634cdd64715bd92e6769af Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 18 Aug 2017 19:13:10 +0200 Subject: Define cmp() for Python 3 (#3517) * Define cmp() for Python 3 http://python-future.org/compatible_idioms.html?highlight=cmp#cmp * Define cmp() for Python 3 http://python-future.org/compatible_idioms.html?highlight=cmp#cmp --- python/google/protobuf/internal/message_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'python/google') diff --git a/python/google/protobuf/internal/message_test.py b/python/google/protobuf/internal/message_test.py index f11bb6d6..dafc8077 100755 --- a/python/google/protobuf/internal/message_test.py +++ b/python/google/protobuf/internal/message_test.py @@ -53,9 +53,13 @@ import six import sys try: - import unittest2 as unittest #PY26 + import unittest2 as unittest # PY26 except ImportError: import unittest +try: + cmp # Python 2 +except NameError: + cmp = lambda(x, y): (x > y) - (x < y) # Python 3 from google.protobuf import map_unittest_pb2 from google.protobuf import unittest_pb2 -- cgit v1.2.3