]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
In library code, replace from io import BytesIO (or StringIO) with import io
authorBob Halley <halley@dnspython.org>
Fri, 1 May 2020 19:38:21 +0000 (12:38 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 1 May 2020 19:38:21 +0000 (12:38 -0700)
dns/dnssec.py
dns/message.py
dns/name.py
dns/node.py
dns/rdataset.py
dns/rdtypes/mxbase.py
dns/rdtypes/nsbase.py
dns/renderer.py
dns/tokenizer.py
dns/zone.py

index 0f31df9d0bdd2f5102a8c39a1456d0388d210619..8e3621a2a6577b334d9b248fb77e65c2282693ae 100644 (file)
@@ -18,7 +18,7 @@
 """Common DNSSEC-related functions and constants."""
 
 import hashlib  # used in make_ds() to avoid pycrypto dependency
-from io import BytesIO
+import io
 import struct
 import time
 import base64
@@ -133,7 +133,7 @@ def algorithm_to_text(value):
 
 
 def _to_rdata(record, origin):
-    s = BytesIO()
+    s = io.BytesIO()
     record.to_wire(s, origin=origin)
     return s.getvalue()
 
index ee9fc84afd0df99566ab293081cd18da5e42354d..935d6b87a8a975a854d8ddeb74b9c3fc2664f588 100644 (file)
@@ -17,7 +17,7 @@
 
 """DNS Messages"""
 
-from io import StringIO
+import io
 import struct
 import time
 
@@ -130,7 +130,7 @@ class Message(object):
         Returns a ``text``.
         """
 
-        s = StringIO()
+        s = io.StringIO()
         s.write('id %d\n' % self.id)
         s.write('opcode %s\n' %
                 dns.opcode.to_text(dns.opcode.from_flags(self.flags)))
index cd4b4468d2556142c780cac4e66cc663e568ccb1..72d2852fced91922bae7a1adbc08873681ee218e 100644 (file)
 """DNS Names.
 """
 
-from io import BytesIO
+import copy
+import io
 import struct
 import sys
-import copy
+
 import encodings.idna
 try:
     import idna
@@ -610,8 +611,8 @@ class Name(object):
     def to_wire(self, file=None, compress=None, origin=None):
         """Convert name to wire format, possibly compressing it.
 
-        *file* is the file where the name is emitted (typically a
-        BytesIO file).  If ``None`` (the default), a ``binary``
+        *file* is the file where the name is emitted (typically an
+        io.BytesIO file).  If ``None`` (the default), a ``binary``
         containing the wire name will be returned.
 
         *compress*, a ``dict``, is the compression table to use.  If
@@ -628,7 +629,7 @@ class Name(object):
         """
 
         if file is None:
-            file = BytesIO()
+            file = io.BytesIO()
             want_return = True
         else:
             want_return = False
index 36e5ffa8bebeb4173f57a0be82978a4d223c0c6c..4f8a16acae75ffd12e188162a0ac95c9a1dc229d 100644 (file)
@@ -17,7 +17,7 @@
 
 """DNS nodes.  A node is a set of rdatasets."""
 
-from io import StringIO
+import io
 
 import dns.rdataset
 import dns.rdatatype
@@ -40,12 +40,14 @@ class Node(object):
         Each rdataset at the node is printed.  Any keyword arguments
         to this method are passed on to the rdataset's to_text() method.
 
-        *name*, a ``dns.name.Name`` or ``text``, the owner name of the rdatasets.
+        *name*, a ``dns.name.Name`` or ``text``, the owner name of the
+        rdatasets.
 
         Returns a ``text``.
+
         """
 
-        s = StringIO()
+        s = io.StringIO()
         for rds in self.rdatasets:
             if len(rds) > 0:
                 s.write(rds.to_text(name, **kw))
index 16a8f891c73f7c1c8b5f2a9d2d26aec8070febbc..98049092c0a6af90e2d9863e2edc328b47165c53 100644 (file)
@@ -17,8 +17,8 @@
 
 """DNS rdatasets (an rdataset is a set of rdatas of a given type and class)"""
 
+import io
 import random
-from io import StringIO
 import struct
 
 import dns.exception
@@ -203,7 +203,7 @@ class Rdataset(dns.set.Set):
         else:
             ntext = ''
             pad = ''
-        s = StringIO()
+        s = io.StringIO()
         if override_rdclass is not None:
             rdclass = override_rdclass
         else:
index a7be7329f3fd668eedf4ae4bb1b2000d850927f6..7e586f648f7b70f73723f81639014bd53308f92f 100644 (file)
@@ -17,7 +17,7 @@
 
 """MX-like base classes."""
 
-from io import BytesIO
+import io
 import struct
 
 import dns.exception
@@ -86,7 +86,7 @@ class UncompressedMX(MXBase):
         super(UncompressedMX, self).to_wire(file, None, origin)
 
     def to_digestable(self, origin=None):
-        f = BytesIO()
+        f = io.BytesIO()
         self.to_wire(f, None, origin)
         return f.getvalue()
 
index 0b588a41efa56094d9c123f4744e6ab5390e3700..6334ce2987666ef25beafa3eda34edd5a48a7c0a 100644 (file)
@@ -17,7 +17,7 @@
 
 """NS-like base classes."""
 
-from io import BytesIO
+import io
 
 import dns.exception
 import dns.rdata
@@ -75,6 +75,6 @@ class UncompressedNS(NSBase):
         super(UncompressedNS, self).to_wire(file, None, origin)
 
     def to_digestable(self, origin=None):
-        f = BytesIO()
+        f = io.BytesIO()
         self.to_wire(f, None, origin)
         return f.getvalue()
index 2325e775d1eb6ba57e8b15067817ef5641999d93..02a9e3d0c23d114e47523ad5cfa5ed856431ab99 100644 (file)
@@ -17,7 +17,7 @@
 
 """Help for building DNS wire format messages"""
 
-from io import BytesIO
+import io
 import struct
 import random
 import time
@@ -54,7 +54,7 @@ class Renderer(object):
         r.add_tsig(keyname, secret, 300, 1, 0, '', request_mac)
         wire = r.get_wire()
 
-    output, a BytesIO, where rendering is written
+    output, an io.BytesIO, where rendering is written
 
     id: the message id
 
@@ -76,7 +76,7 @@ class Renderer(object):
     def __init__(self, id=None, flags=0, max_size=65535, origin=None):
         """Initialize a new renderer."""
 
-        self.output = BytesIO()
+        self.output = io.BytesIO()
         if id is None:
             self.id = random.randint(0, 65535)
         else:
index 479c002dd48e07b97426678100efd6a4e4bc3af6..66714b7fac3c0aa5ce125e717baf5b3533bc5536 100644 (file)
@@ -17,7 +17,7 @@
 
 """Tokenize DNS master file format"""
 
-from io import StringIO
+import io
 import sys
 
 import dns.exception
@@ -189,11 +189,11 @@ class Tokenizer(object):
         """
 
         if isinstance(f, str):
-            f = StringIO(f)
+            f = io.StringIO(f)
             if filename is None:
                 filename = '<string>'
         elif isinstance(f, bytes):
-            f = StringIO(f.decode())
+            f = io.StringIO(f.decode())
             if filename is None:
                 filename = '<string>'
         else:
index 556fda0569d1d934d2831655ab7737376777dec9..f403bd84fc011956472c8d3653bbdfb365afdb27 100644 (file)
 
 """DNS Zones."""
 
-import sys
-import re
+import io
 import os
-from io import StringIO
+import re
+import sys
 
 import dns.exception
 import dns.name
@@ -551,7 +551,7 @@ class Zone(object):
         LF on POSIX, CRLF on Windows, CR on Macintosh).
         @type nl: string or None
         """
-        temp_buffer = StringIO()
+        temp_buffer = io.StringIO()
         self.to_file(temp_buffer, sorted, relativize, nl)
         return_value = temp_buffer.getvalue()
         temp_buffer.close()