diff options
author | 2017-08-18 10:11:30 -0700 | |
---|---|---|
committer | 2017-08-18 10:11:30 -0700 | |
commit | 1aa2c34387535d21aa15cd89fac3cf0169e9d63d (patch) | |
tree | 59fb0cc128eb85f00a2b03ffcfa9eff744db4d62 /python/google/protobuf/internal | |
parent | 5ab8ae75668d38db44e8d23437170f8f108a7581 (diff) | |
parent | dded80f92404efeabe00b61a0f9646eef4dd650a (diff) |
Merge pull request #3516 from cclauss/patch-3
Python 3 compatibility fixes: print(), long(), etc.
Diffstat (limited to 'python/google/protobuf/internal')
-rwxr-xr-x | python/google/protobuf/internal/test_util.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python/google/protobuf/internal/test_util.py b/python/google/protobuf/internal/test_util.py index 269d0e2d..9434b7b1 100755 --- a/python/google/protobuf/internal/test_util.py +++ b/python/google/protobuf/internal/test_util.py @@ -39,11 +39,15 @@ __author__ = 'robinson@google.com (Will Robinson)' import numbers import operator import os.path -import sys from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_pb2 -from google.protobuf import descriptor_pb2 + +try: + long # Python 2 +except NameError: + long = int # Python 3 + # Tests whether the given TestAllTypes message is proto2 or not. # This is used to gate several fields/features that only exist @@ -51,6 +55,7 @@ from google.protobuf import descriptor_pb2 def IsProto2(message): return message.DESCRIPTOR.syntax == "proto2" + def SetAllNonLazyFields(message): """Sets every non-lazy field in the message to a unique value. @@ -707,8 +712,8 @@ class NonStandardInteger(numbers.Integral): NonStandardInteger is the minimal legal specification for a custom Integral. As such, it does not support 0 < x < 5 and it is not hashable. - Note: This is added here instead of relying on numpy or a similar library with - custom integers to limit dependencies. + Note: This is added here instead of relying on numpy or a similar library + with custom integers to limit dependencies. """ def __init__(self, val, error_string_on_conversion=None): @@ -845,4 +850,3 @@ class NonStandardInteger(numbers.Integral): def __repr__(self): return 'NonStandardInteger(%s)' % self.val - |