Browse Source

fix cmp in Python 3

dev
破娃酱 8 years ago
parent
commit
b89931f9fc
  1. 12
      shadowsocks/common.py

12
shadowsocks/common.py

@ -297,6 +297,12 @@ class IPNetwork(object):
def __cmp__(self, other): def __cmp__(self, other):
return cmp(self.addrs_str, other.addrs_str) return cmp(self.addrs_str, other.addrs_str)
def __eq__(self, other):
return self.addrs_str == other.addrs_str
def __ne__(self, other):
return self.addrs_str != other.addrs_str
class PortRange(object): class PortRange(object):
def __init__(self, range_str): def __init__(self, range_str):
self.range_str = to_str(range_str) self.range_str = to_str(range_str)
@ -328,6 +334,12 @@ class PortRange(object):
def __cmp__(self, other): def __cmp__(self, other):
return cmp(self.range_str, other.range_str) return cmp(self.range_str, other.range_str)
def __eq__(self, other):
return self.range_str == other.range_str
def __ne__(self, other):
return self.range_str != other.range_str
def test_inet_conv(): def test_inet_conv():
ipv4 = b'8.8.4.4' ipv4 = b'8.8.4.4'
b = inet_pton(socket.AF_INET, ipv4) b = inet_pton(socket.AF_INET, ipv4)

Loading…
Cancel
Save