This repository was archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
No module named lib2to3 with python-3.13 #130
Copy link
Copy link
Open
Description
Hi.
I can't install ipaddr-py on my newest Gentoo. There is no module lib2to3 in Python-3.13.
I'm manually converted *.py files on another machine with Python-3.12 via lib2to3.
Listed below diff resolve this issue for me.
diff '--color=auto' -Naur a/ipaddr.py b/ipaddr.py
--- a/ipaddr.py>2017-09-15 21:35:54.000000000 +0300
+++ b/ipaddr.py>2024-05-30 11:35:05.191731657 +0300
@@ -521,7 +521,7 @@
return '%s' % self._string_from_ip_int(self._ip)
.
def __hash__(self):
- return hash(hex(long(self._ip)))
+ return hash(hex(int(self._ip)))
.
def _get_address_key(self):
return (self._version, self)
@@ -896,7 +896,7 @@
Raises:
NetmaskValueError: If the input is not an integer, or out of range.
"""
- if not isinstance(prefixlen, (int, long)):
+ if not isinstance(prefixlen, int):
raise NetmaskValueError('%r is not an integer' % prefixlen)
prefixlen = int(prefixlen)
if not (0 <= prefixlen <= self._max_prefixlen):
@@ -1158,7 +1158,7 @@
.
"""
octets = []
- for _ in xrange(4):
+ for _ in range(4):
octets.insert(0, str(ip_int & 0xFF))
ip_int >>= 8
return '.'.join(octets)
@@ -1271,7 +1271,7 @@
return
.
# Efficient constructor from integer.
- if isinstance(address, (int, long)):
+ if isinstance(address, int):
self._ip = address
if address < 0 or address > self._ALL_ONES:
raise AddressValueError(address)
@@ -1353,7 +1353,7 @@
_BaseV4.__init__(self, address)
.
# Constructing from a single IP address.
- if isinstance(address, (int, long, Bytes, IPv4Address)):
+ if isinstance(address, (int, Bytes, IPv4Address)):
self.ip = IPv4Address(address)
self._ip = self.ip._ip
self._prefixlen = self._max_prefixlen
@@ -1457,7 +1457,7 @@
# This indicates that a run of zeroes has been skipped.
try:
skip_index, = (
- [i for i in xrange(1, len(parts) - 1) if not parts[i]] or
+ [i for i in range(1, len(parts) - 1) if not parts[i]] or
[None])
except ValueError:
# Can't have more than one '::'
@@ -1491,12 +1491,12 @@
.
try:
# Now, parse the hextets into a 128-bit integer.
- ip_int = long(0)
- for i in xrange(parts_hi):
+ ip_int = int(0)
+ for i in range(parts_hi):
ip_int <<= 16
ip_int |= self._parse_hextet(parts[i])
ip_int <<= 16 * parts_skipped
- for i in xrange(-parts_lo, 0):
+ for i in range(-parts_lo, 0):
ip_int <<= 16
ip_int |= self._parse_hextet(parts[i])
return ip_int
@@ -1617,7 +1617,7 @@
.
ip_int = self._ip_int_from_string(ip_str)
parts = []
- for i in xrange(self._HEXTET_COUNT):
+ for i in range(self._HEXTET_COUNT):
parts.append('%04x' % (ip_int & 0xFFFF))
ip_int >>= 16
parts.reverse()
@@ -1802,7 +1802,7 @@
return
.
# Efficient constructor from integer.
- if isinstance(address, (int, long)):
+ if isinstance(address, int):
self._ip = address
if address < 0 or address > self._ALL_ONES:
raise AddressValueError(address)
@@ -1880,7 +1880,7 @@
_BaseV6.__init__(self, address)
.
# Constructing from a single IP address.
- if isinstance(address, (int, long, Bytes, IPv6Address)):
+ if isinstance(address, (int, Bytes, IPv6Address)):
self.ip = IPv6Address(address)
self._ip = self.ip._ip
self._prefixlen = self._max_prefixlen
diff '--color=auto' -Naur a/ipaddr_test.py b/ipaddr_test.py
--- a/ipaddr_test.py<-->2017-09-15 03:18:44.000000000 +0300
+++ b/ipaddr_test.py<-->2024-05-30 11:35:06.456722898 +0300
@@ -1035,7 +1035,7 @@
# i70
self.assertEqual(hash(ipaddr.IPAddress('1.2.3.4')),
hash(ipaddr.IPAddress(
- long(ipaddr.IPAddress('1.2.3.4')._ip))))
+ int(ipaddr.IPAddress('1.2.3.4')._ip))))
ip1 = ipaddr.IPAddress('10.1.1.0')
ip2 = ipaddr.IPAddress('1::')
dummy = {}
@@ -1082,7 +1082,7 @@
'7:6:5:4:3:2:1::': '7:6:5:4:3:2:1:0/128',
'0:6:5:4:3:2:1::': '0:6:5:4:3:2:1:0/128',
}
- for uncompressed, compressed in test_addresses.items():
+ for uncompressed, compressed in list(test_addresses.items()):
self.assertEqual(compressed, str(ipaddr.IPv6Network(uncompressed)))
.
def testExplodeShortHandIpStr(self):
Metadata
Metadata
Assignees
Labels
No labels