105 строки
3.9 KiB
Diff
Executable File
105 строки
3.9 KiB
Diff
Executable File
diff -ru ipaddr-2.1.11/ipaddr.py ipaddr-2.1.11-modified/ipaddr.py
|
|
--- ipaddr-2.1.11/ipaddr.py 2014-01-31 13:22:32.000000000 -0800
|
|
+++ ipaddr-2.1.11-modified/ipaddr.py 2017-05-16 16:22:19.672536346 -0700
|
|
@@ -25,6 +25,11 @@
|
|
__version__ = '2.1.11'
|
|
|
|
import struct
|
|
+import sys
|
|
+
|
|
+if sys.version_info > (3,):
|
|
+ long = int
|
|
+ xrange = range
|
|
|
|
IPV4LENGTH = 32
|
|
IPV6LENGTH = 128
|
|
@@ -1447,7 +1452,7 @@
|
|
|
|
try:
|
|
# Now, parse the hextets into a 128-bit integer.
|
|
- ip_int = 0L
|
|
+ ip_int = long(0)
|
|
for i in xrange(parts_hi):
|
|
ip_int <<= 16
|
|
ip_int |= self._parse_hextet(parts[i])
|
|
diff -ru ipaddr-2.1.11/ipaddr_test.py ipaddr-2.1.11-modified/ipaddr_test.py
|
|
--- ipaddr-2.1.11/ipaddr_test.py 2014-01-31 13:02:28.000000000 -0800
|
|
+++ ipaddr-2.1.11-modified/ipaddr_test.py 2017-05-16 16:29:41.029226835 -0700
|
|
@@ -21,6 +21,11 @@
|
|
import unittest
|
|
import time
|
|
import ipaddr
|
|
+import sys
|
|
+
|
|
+if sys.version_info > (3,):
|
|
+ long = int
|
|
+
|
|
|
|
# Compatibility function to cast str to bytes objects
|
|
if issubclass(ipaddr.Bytes, str):
|
|
@@ -266,7 +271,7 @@
|
|
'2001:658:22a:cafe:200::1')
|
|
|
|
def testGetNetmask(self):
|
|
- self.assertEqual(int(self.ipv4.netmask), 4294967040L)
|
|
+ self.assertEqual(int(self.ipv4.netmask), 4294967040)
|
|
self.assertEqual(str(self.ipv4.netmask), '255.255.255.0')
|
|
self.assertEqual(str(self.ipv4_hostmask.netmask), '255.0.0.0')
|
|
self.assertEqual(int(self.ipv6.netmask),
|
|
@@ -283,7 +288,7 @@
|
|
self.assertEqual(ipv6_zero_netmask._prefix_from_prefix_string('0'), 0)
|
|
|
|
def testGetBroadcast(self):
|
|
- self.assertEqual(int(self.ipv4.broadcast), 16909311L)
|
|
+ self.assertEqual(int(self.ipv4.broadcast), 16909311)
|
|
self.assertEqual(str(self.ipv4.broadcast), '1.2.3.255')
|
|
|
|
self.assertEqual(int(self.ipv6.broadcast),
|
|
@@ -1100,9 +1105,9 @@
|
|
|
|
def testNetworkElementCaching(self):
|
|
# V4 - make sure we're empty
|
|
- self.assertFalse(self.ipv4._cache.has_key('network'))
|
|
- self.assertFalse(self.ipv4._cache.has_key('broadcast'))
|
|
- self.assertFalse(self.ipv4._cache.has_key('hostmask'))
|
|
+ self.assertFalse('network' in self.ipv4._cache)
|
|
+ self.assertFalse('broadcast' in self.ipv4._cache)
|
|
+ self.assertFalse('hostmask' in self.ipv4._cache)
|
|
|
|
# V4 - populate and test
|
|
self.assertEqual(self.ipv4.network, ipaddr.IPv4Address('1.2.3.0'))
|
|
@@ -1110,14 +1115,14 @@
|
|
self.assertEqual(self.ipv4.hostmask, ipaddr.IPv4Address('0.0.0.255'))
|
|
|
|
# V4 - check we're cached
|
|
- self.assertTrue(self.ipv4._cache.has_key('network'))
|
|
- self.assertTrue(self.ipv4._cache.has_key('broadcast'))
|
|
- self.assertTrue(self.ipv4._cache.has_key('hostmask'))
|
|
+ self.assertTrue('network' in self.ipv4._cache)
|
|
+ self.assertTrue('broadcast' in self.ipv4._cache)
|
|
+ self.assertTrue('hostmask' in self.ipv4._cache)
|
|
|
|
# V6 - make sure we're empty
|
|
- self.assertFalse(self.ipv6._cache.has_key('network'))
|
|
- self.assertFalse(self.ipv6._cache.has_key('broadcast'))
|
|
- self.assertFalse(self.ipv6._cache.has_key('hostmask'))
|
|
+ self.assertFalse('network' in self.ipv6._cache)
|
|
+ self.assertFalse('broadcast' in self.ipv6._cache)
|
|
+ self.assertFalse('hostmask' in self.ipv6._cache)
|
|
|
|
# V6 - populate and test
|
|
self.assertEqual(self.ipv6.network,
|
|
@@ -1128,9 +1133,9 @@
|
|
ipaddr.IPv6Address('::ffff:ffff:ffff:ffff'))
|
|
|
|
# V6 - check we're cached
|
|
- self.assertTrue(self.ipv6._cache.has_key('network'))
|
|
- self.assertTrue(self.ipv6._cache.has_key('broadcast'))
|
|
- self.assertTrue(self.ipv6._cache.has_key('hostmask'))
|
|
+ self.assertTrue('network' in self.ipv6._cache)
|
|
+ self.assertTrue('broadcast' in self.ipv6._cache)
|
|
+ self.assertTrue('hostmask' in self.ipv6._cache)
|
|
|
|
def testTeredo(self):
|
|
# stolen from wikipedia
|