]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
remove bytearray() wrapping used for python 2 compatibility
authorBob Halley <halley@dnspython.org>
Sat, 5 Jan 2019 18:07:02 +0000 (10:07 -0800)
committerBob Halley <halley@dnspython.org>
Sat, 5 Jan 2019 18:07:02 +0000 (10:07 -0800)
dns/dnssec.py
dns/ipv4.py
dns/ipv6.py
dns/name.py
dns/rdata.py
dns/reversename.py
dns/wiredata.py
tests/test_nsec3.py
tests/test_wiredata.py

index d5bd3fe75e58de468f7680f2138dc96d112b5f89..62ca5a155d9633f43433ee638a633b6e0a4f536a 100644 (file)
@@ -130,7 +130,6 @@ def key_id(key, origin=None):
     """
 
     rdata = _to_rdata(key, origin)
-    rdata = bytearray(rdata)
     if key.algorithm == RSAMD5:
         return (rdata[-3] << 8) + rdata[-2]
     else:
index c35775b483d1ba88c9a354c267c31b3e13a3749b..ca6386d4d1d24422f507d31fcbd32e96e03daf55 100644 (file)
@@ -31,8 +31,6 @@ def inet_ntoa(address):
 
     if len(address) != 4:
         raise dns.exception.SyntaxError
-    if not isinstance(address, bytearray):
-        address = bytearray(address)
     return ('%u.%u.%u.%u' % (address[0], address[1],
                              address[2], address[3]))
 
index e501a41a364ec70ff24fbf73ac07894ae4cddb2f..1f703a67f6766dc2e18150e318b3d4645bc61f29 100644 (file)
@@ -117,7 +117,7 @@ def inet_aton(text):
     #
     m = _v4_ending.match(text)
     if not m is None:
-        b = bytearray(dns.ipv4.inet_aton(m.group(2)))
+        b = dns.ipv4.inet_aton(m.group(2))
         text = (u"{}:{:02x}{:02x}:{:02x}{:02x}".format(m.group(1).decode(),
                                                        b[0], b[1], b[2],
                                                        b[3])).encode()
index 10167435d3a3976f7ac114703b66c9ba1bb45414..84968c16321b7a88b818441b37fff76781de2afa 100644 (file)
@@ -227,7 +227,7 @@ class IDNA2008Codec(IDNACodec):
         except idna.IDNAError as e:
             raise IDNAException(idna_exception=e)
 
-_escaped = bytearray(b'"().;\\@$')
+_escaped = b'"().;\\@$'
 
 IDNA_2003_Practical = IDNA2003Codec(False)
 IDNA_2003_Strict = IDNA2003Codec(True)
@@ -248,7 +248,7 @@ def _escapify(label, unicode_mode=False):
         text = ''
         if isinstance(label, str):
             label = label.encode()
-        for c in bytearray(label):
+        for c in label:
             if c in _escaped:
                 text += '\\' + chr(c)
             elif c > 0x20 and c < 0x7F:
@@ -374,7 +374,7 @@ class Name(object):
 
         h = 0
         for label in self.labels:
-            for c in bytearray(label.lower()):
+            for c in label.lower():
                 h += (h << 3) + c
         return h % maxint
 
@@ -899,7 +899,7 @@ def from_text(text, origin=root, idna_codec=None):
     if text:
         if text == b'.':
             return Name([b''])
-        for c in bytearray(text):
+        for c in text:
             byte_ = struct.pack('!B', c)
             if escaping:
                 if edigits == 0:
index 01930a4f7f684f899256e7796c24b3c80586f7af..93b4a31f73f655d2c97605801b98253d0915e4ae 100644 (file)
@@ -59,7 +59,7 @@ def _base64ify(data, chunksize=_base64_chunksize):
                       for i
                       in range(0, len(line), chunksize)]).decode()
 
-__escaped = bytearray(b'"\\')
+__escaped = b'"\\'
 
 def _escapify(qstring):
     """Escape the characters in a quoted string which need it."""
index 60618cc98c16e8192a914dbc4fbb35887d88bf1d..0e10bec002ed3688021a48b642bb837021f0adbe 100644 (file)
@@ -49,7 +49,7 @@ def from_address(text):
             origin = ipv6_reverse_domain
     except Exception:
         parts = ['%d' %
-                 byte for byte in bytearray(dns.ipv4.inet_aton(text))]
+                 byte for byte in dns.ipv4.inet_aton(text)]
         origin = ipv4_reverse_domain
     parts.reverse()
     return dns.name.from_text('.'.join(parts), origin=origin)
index 85412691c07ca7819bbe1c7c7c1e2cec3abb4662..14f36fc12aa6801df136a19665bd47ae7fd9fb92 100644 (file)
@@ -54,7 +54,7 @@ class WireData(bytes):
 
                 return WireData(super(WireData, self).__getitem__(
                     slice(start, stop)))
-            return bytearray(self.unwrap())[key]
+            return self.unwrap()[key]
         except IndexError:
             raise dns.exception.FormError
 
index 019dc48b722cc0e24c570fecf66e2fe701997fdf..c07d3acae1ba381f01b6536acaef20c763967156 100644 (file)
@@ -29,8 +29,8 @@ class NSEC3TestCase(unittest.TestCase):
                 u"1 0 100 ABCD SCBCQHKU35969L2A68P3AD59LHF30715 A CAA TYPE65534")
         bitmap = bytearray(b'\0' * 32)
         bitmap[31] = bitmap[31] | 2
-        self.assertEqual(rdata.windows, [(0, bytearray(b'@')),
-                                         (1, bytearray(b'@')), # CAA = 257
+        self.assertEqual(rdata.windows, [(0, b'@'),
+                                         (1, b'@'), # CAA = 257
                                          (255, bitmap)
                                         ])
 
index 9644de4702e60f5184de4c1f4c2ea50b854f8c2c..7b59c3cd14e651d318047d6409eb17ad95cf2d76 100644 (file)
@@ -59,10 +59,10 @@ class WireDataSlicingTestCase(unittest.TestCase):
         """Get data one by one item"""
         data = b'0123456789'
         inst = WireData(data)
-        for i, byte in enumerate(bytearray(data)):
+        for i, byte in enumerate(data):
             self.assertEqual(inst[i], byte)
         for i in range(-1, len(data) * -1, -1):
-            self.assertEqual(inst[i], bytearray(data)[i])
+            self.assertEqual(inst[i], data[i])
 
     def testEmptySlice(self):
         """Test empty slice"""