From 34ed6bd399af49c3cce9dca54287c2300252de01 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Wed, 12 Aug 2015 09:07:11 -0400 Subject: [PATCH] Python3 no longer uses __cmp__, incorrect initialization for octet strings --- py34/bacpypes/primitivedata.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/py34/bacpypes/primitivedata.py b/py34/bacpypes/primitivedata.py index 6539e3a..591b81d 100755 --- a/py34/bacpypes/primitivedata.py +++ b/py34/bacpypes/primitivedata.py @@ -451,6 +451,8 @@ class Atomic(object): _app_tag = None def __cmp__(self, other): + # sys.stderr.write("__cmp__ %r %r\n" % (self, other)) + # hoop jump it if not isinstance(other, self.__class__): other = self.__class__(other) @@ -463,6 +465,26 @@ class Atomic(object): else: return 0 + def __lt__(self, other): + # sys.stderr.write("__lt__ %r %r\n" % (self, other)) + + # hoop jump it + if not isinstance(other, self.__class__): + other = self.__class__(other) + + # now compare the values + return (self.value < other.value) + + def __eq__(self, other): + sys.stderr.write("__eq__ %r %r\n" % (self, other)) + + # hoop jump it + if not isinstance(other, self.__class__): + other = self.__class__(other) + + # now compare the values + return self.value == other.value + # # Null # @@ -738,7 +760,7 @@ class OctetString(Atomic): _app_tag = Tag.octetStringAppTag def __init__(self, arg=None): - self.value = '' + self.value = bytes() if arg is None: pass