File py3_fixes.patch of Package python-dnspython.14982
--- dns/edns.py.orig
+++ dns/edns.py
@@ -114,7 +114,7 @@ class GenericOption(Option):
from_wire = classmethod(from_wire)
def _cmp(self, other):
- return cmp(self.data, other.data)
+ return cmp(self.data, other.data)
_type_to_class = {
}
--- dns/entropy.py.orig
+++ dns/entropy.py
@@ -101,18 +101,18 @@ class EntropyPool(object):
def random_between(self, first, last):
size = last - first + 1
- if size > 4294967296L:
+ if size > long(4294967296):
raise ValueError('too big')
if size > 65536:
rand = self.random_32
- max = 4294967295L
+ max = long(4294967295)
elif size > 256:
rand = self.random_16
max = 65535
else:
rand = self.random_8
max = 255
- return (first + size * rand() // (max + 1))
+ return (first + size * rand() // (max + 1))
pool = EntropyPool()
--- dns/flags.py.orig
+++ dns/flags.py
@@ -48,12 +48,12 @@ _edns_by_text = {
# cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
# would cause the mappings not to be true inverses.
-_by_value = dict([(y, x) for x, y in _by_text.iteritems()])
+_by_value = dict([(y, x) for x, y in _by_text.items()])
-_edns_by_value = dict([(y, x) for x, y in _edns_by_text.iteritems()])
+_edns_by_value = dict([(y, x) for x, y in _edns_by_text.items()])
def _order_flags(table):
- order = list(table.iteritems())
+ order = list(table.items())
order.sort()
order.reverse()
return order
--- dns/message.py.orig
+++ dns/message.py
@@ -15,7 +15,8 @@
"""DNS Messages"""
-import cStringIO
+#import cStringIO
+from io import StringIO
import random
import struct
import sys
@@ -173,7 +174,7 @@ class Message(object):
self.index = {}
def __repr__(self):
- return '<DNS message, ID ' + `self.id` + '>'
+ return '<DNS message, ID ' + repr(self.id) + '>'
def __str__(self):
return self.to_text()
@@ -499,7 +500,7 @@ class Message(object):
options = []
else:
# make sure the EDNS version in ednsflags agrees with edns
- ednsflags &= 0xFF00FFFFL
+ ednsflags &= long(0xFF00FFFF)
ednsflags |= (edns << 16)
if options is None:
options = []
@@ -537,7 +538,7 @@ class Message(object):
(value, evalue) = dns.rcode.to_flags(rcode)
self.flags &= 0xFFF0
self.flags |= value
- self.ednsflags &= 0x00FFFFFFL
+ self.ednsflags &= long(0x00FFFFFF)
self.ednsflags |= evalue
if self.ednsflags != 0 and self.edns < 0:
self.edns = 0
--- dns/name.py.orig
+++ dns/name.py
@@ -21,7 +21,8 @@
@type empty: dns.name.Name object
"""
-import cStringIO
+#import cStringIO
+from io import StringIO
import struct
import sys
import copy
@@ -180,7 +181,7 @@ class Name(object):
@rtype: int
"""
- h = 0L
+ h = long(0)
for label in self.labels:
for c in label:
h += ( h << 3 ) + ord(c.lower())
--- dns/opcode.py.orig
+++ dns/opcode.py
@@ -35,7 +35,7 @@ _by_text = {
# cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
# would cause the mapping not to be true inverse.
-_by_value = dict([(y, x) for x, y in _by_text.iteritems()])
+_by_value = dict([(y, x) for x, y in _by_text.items()])
class UnknownOpcode(dns.exception.DNSException):
--- dns/query.py.orig
+++ dns/query.py
@@ -115,7 +115,7 @@ def _wait_for(fd, readable, writable, er
try:
if not _polling_backend(fd, readable, writable, error, timeout):
raise dns.exception.Timeout
- except select.error, e:
+ except select.error as e:
if e.args[0] != errno.EINTR:
raise e
done = True
--- dns/rcode.py.orig
+++ dns/rcode.py
@@ -49,7 +49,7 @@ _by_text = {
# cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
# would cause the mapping not to be a true inverse.
-_by_value = dict([(y, x) for x, y in _by_text.iteritems()])
+_by_value = dict([(y, x) for x, y in _by_text.items()])
class UnknownRcode(dns.exception.DNSException):
--- dns/rdata.py.orig
+++ dns/rdata.py
@@ -25,7 +25,8 @@ default is 'dns.rdtypes'. Changing this
chunk of hexstring that _hexify() produces before whitespace occurs.
@type _hex_chunk: int"""
-import cStringIO
+#import cStringIO
+from io import StringIO
import dns.exception
import dns.name
--- dns/rdataclass.py.orig
+++ dns/rdataclass.py
@@ -47,7 +47,7 @@ _by_text = {
# cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
# would cause the mapping not to be true inverse.
-_by_value = dict([(y, x) for x, y in _by_text.iteritems()])
+_by_value = dict([(y, x) for x, y in _by_text.items()])
# Now that we've built the inverse map, we can add class aliases to
# the _by_text mapping.
@@ -100,7 +100,7 @@ def to_text(value):
raise ValueError("class must be between >= 0 and <= 65535")
text = _by_value.get(value)
if text is None:
- text = 'CLASS' + `value`
+ text = 'CLASS' + repr(value)
return text
def is_metaclass(rdclass):
--- dns/rdataset.py.orig
+++ dns/rdataset.py
@@ -16,7 +16,8 @@
"""DNS rdatasets (an rdataset is a set of rdatas of a given type and class)"""
import random
-import StringIO
+#import StringIO
+from io import StringIO
import struct
import dns.exception
--- dns/rdatatype.py.orig
+++ dns/rdatatype.py
@@ -160,7 +160,7 @@ _by_text = {
# cannot make any mistakes (e.g. omissions, cut-and-paste errors) that
# would cause the mapping not to be true inverse.
-_by_value = dict([(y, x) for x, y in _by_text.iteritems()])
+_by_value = dict([(y, x) for x, y in _by_text.items()])
_metatypes = {
@@ -210,7 +210,7 @@ def to_text(value):
raise ValueError("type must be between >= 0 and <= 65535")
text = _by_value.get(value)
if text is None:
- text = 'TYPE' + `value`
+ text = 'TYPE' + repr(value)
return text
def is_metatype(rdtype):
--- dns/renderer.py.orig
+++ dns/renderer.py
@@ -15,7 +15,8 @@
"""Help for building DNS wire format messages"""
-import cStringIO
+#import cStringIO
+from io import StringIO
import struct
import random
import time
@@ -218,7 +219,7 @@ class Renderer(object):
"""
# make sure the EDNS version in ednsflags agrees with edns
- ednsflags &= 0xFF00FFFFL
+ ednsflags &= long(0xFF00FFFF)
ednsflags |= (edns << 16)
self._set_section(ADDITIONAL)
before = self.output.tell()
--- dns/tokenizer.py.orig
+++ dns/tokenizer.py
@@ -15,7 +15,8 @@
"""Tokenize DNS master file format"""
-import cStringIO
+#import cStringIO
+from io import StringIO
import sys
import dns.exception
@@ -488,7 +489,7 @@ class Tokenizer(object):
if not token.value.isdigit():
raise dns.exception.SyntaxError('expecting an integer')
value = long(token.value)
- if value < 0 or value > 4294967296L:
+ if value < 0 or value > long(4294967296):
raise dns.exception.SyntaxError('%d is not an unsigned 32-bit integer' % value)
return value
--- dns/tsig.py.orig
+++ dns/tsig.py
@@ -93,9 +93,9 @@ def sign(wire, keyname, secret, time, fu
ctx.update(keyname.to_digestable())
ctx.update(struct.pack('!H', dns.rdataclass.ANY))
ctx.update(struct.pack('!I', 0))
- long_time = time + 0L
- upper_time = (long_time >> 32) & 0xffffL
- lower_time = long_time & 0xffffffffL
+ long_time = time + long(0)
+ upper_time = (long_time >> 32) & long(0xffff)
+ lower_time = long_time & long(0xffffffff)
time_mac = struct.pack('!HIH', upper_time, lower_time, fudge)
pre_mac = algorithm_name + time_mac
ol = len(other_data)
@@ -145,7 +145,7 @@ def validate(wire, keyname, secret, now,
current = current + used
(upper_time, lower_time, fudge, mac_size) = \
struct.unpack("!HIHH", wire[current:current + 10])
- time = ((upper_time + 0L) << 32) + (lower_time + 0L)
+ time = ((upper_time + long(0)) << 32) + (lower_time + long(0))
current += 10
mac = wire[current:current + mac_size]
current += mac_size
--- dns/ttl.py.orig
+++ dns/ttl.py
@@ -36,8 +36,8 @@ def from_text(text):
else:
if not text[0].isdigit():
raise BadTTL
- total = 0L
- current = 0L
+ total = long(0)
+ current = long(0)
for c in text:
if c.isdigit():
current *= 10
@@ -45,13 +45,13 @@ def from_text(text):
else:
c = c.lower()
if c == 'w':
- total += current * 604800L
+ total += current * long(604800)
elif c == 'd':
- total += current * 86400L
+ total += current * long(86400)
elif c == 'h':
- total += current * 3600L
+ total += current * long(3600)
elif c == 'm':
- total += current * 60L
+ total += current * long(60)
elif c == 's':
total += current
else:
@@ -59,6 +59,6 @@ def from_text(text):
current = 0
if not current == 0:
raise BadTTL("trailing integer")
- if total < 0L or total > 2147483647L:
+ if total < long(0) or total > long(2147483647):
raise BadTTL("TTL should be between 0 and 2^31 - 1 (inclusive)")
return total