summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Manna <kyle@kylemanna.com>2015-09-19 15:03:13 -0700
committerKyle Manna <kyle@kylemanna.com>2015-09-20 18:49:42 -0700
commit0d7ef5f936afc32bfe0aaec8b92667d4c3a026a0 (patch)
tree8eca6d2d467d8b5940df302c3ddc2f4d785f7a83
parent56134e87657714b50d9837f846410fc30fa9fe7b (diff)
generator: Remove cmp() to work with Python3
* Python3 ignores cmp() and __cmp__() and only needs __lt__() for sorting. Delete and update as appropriate. * Ref: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
-rwxr-xr-xgenerator/nanopb_generator.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 240fa15f..f7d43221 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -314,8 +314,8 @@ class Field:
else:
raise NotImplementedError(desc.type)
- def __cmp__(self, other):
- return cmp(self.tag, other.tag)
+ def __lt__(self, other):
+ return self.tag < other.tag
def __str__(self):
result = ''
@@ -661,9 +661,6 @@ class OneOf(Field):
# Sort by the lowest tag number inside union
self.tag = min([f.tag for f in self.fields])
- def __cmp__(self, other):
- return cmp(self.tag, other.tag)
-
def __str__(self):
result = ''
if self.fields: