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 --- .../v2.5.0/tests/google/protobuf/internal/message_test.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'python/compatibility_tests') diff --git a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py index 53e9d507..5053f035 100755 --- a/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py +++ b/python/compatibility_tests/v2.5.0/tests/google/protobuf/internal/message_test.py @@ -55,6 +55,11 @@ from google.protobuf.internal import api_implementation from google.protobuf.internal import test_util from google.protobuf import message +try: + cmp # Python 2 +except NameError: + cmp = lambda(x, y): (x > y) - (x < y) # Python 3 + # Python pre-2.6 does not have isinf() or isnan() functions, so we have # to provide our own. def isnan(val): -- cgit v1.2.3