]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
remove the rest of the unicode string prefixes
authorBob Halley <halley@dnspython.org>
Tue, 8 Jan 2019 15:03:46 +0000 (07:03 -0800)
committerBob Halley <halley@dnspython.org>
Tue, 8 Jan 2019 15:03:46 +0000 (07:03 -0800)
dns/message.py
dns/node.py
dns/rdataset.py
dns/rdtypes/ANY/HIP.py
dns/rdtypes/ANY/NSEC3.py
dns/zone.py
tests/test_bugs.py
tests/test_name.py
tests/test_tokenizer.py
tests/test_zone.py

index c91484a56dc3b341c77e2eae993f00d7c79b8547..e720a4e73c43c172d1de9c332ef26b3ad33345df 100644 (file)
@@ -133,46 +133,46 @@ class Message(object):
         """
 
         s = StringIO()
-        s.write(u'id %d\n' % self.id)
-        s.write(u'opcode %s\n' %
+        s.write('id %d\n' % self.id)
+        s.write('opcode %s\n' %
                 dns.opcode.to_text(dns.opcode.from_flags(self.flags)))
         rc = dns.rcode.from_flags(self.flags, self.ednsflags)
-        s.write(u'rcode %s\n' % dns.rcode.to_text(rc))
-        s.write(u'flags %s\n' % dns.flags.to_text(self.flags))
+        s.write('rcode %s\n' % dns.rcode.to_text(rc))
+        s.write('flags %s\n' % dns.flags.to_text(self.flags))
         if self.edns >= 0:
-            s.write(u'edns %s\n' % self.edns)
+            s.write('edns %s\n' % self.edns)
             if self.ednsflags != 0:
-                s.write(u'eflags %s\n' %
+                s.write('eflags %s\n' %
                         dns.flags.edns_to_text(self.ednsflags))
-            s.write(u'payload %d\n' % self.payload)
+            s.write('payload %d\n' % self.payload)
         for opt in self.options:
-            s.write(u'option %s\n' % opt.to_text())
+            s.write('option %s\n' % opt.to_text())
         is_update = dns.opcode.is_update(self.flags)
         if is_update:
-            s.write(u';ZONE\n')
+            s.write(';ZONE\n')
         else:
-            s.write(u';QUESTION\n')
+            s.write(';QUESTION\n')
         for rrset in self.question:
             s.write(rrset.to_text(origin, relativize, **kw))
-            s.write(u'\n')
+            s.write('\n')
         if is_update:
-            s.write(u';PREREQ\n')
+            s.write(';PREREQ\n')
         else:
-            s.write(u';ANSWER\n')
+            s.write(';ANSWER\n')
         for rrset in self.answer:
             s.write(rrset.to_text(origin, relativize, **kw))
-            s.write(u'\n')
+            s.write('\n')
         if is_update:
-            s.write(u';UPDATE\n')
+            s.write(';UPDATE\n')
         else:
-            s.write(u';AUTHORITY\n')
+            s.write(';AUTHORITY\n')
         for rrset in self.authority:
             s.write(rrset.to_text(origin, relativize, **kw))
-            s.write(u'\n')
-        s.write(u';ADDITIONAL\n')
+            s.write('\n')
+        s.write(';ADDITIONAL\n')
         for rrset in self.additional:
             s.write(rrset.to_text(origin, relativize, **kw))
-            s.write(u'\n')
+            s.write('\n')
         #
         # We strip off the final \n so the caller can print the result without
         # doing weird things to get around eccentricities in Python print
index 8a7f19f5234b336665413c457ca5c89d7131790c..36e5ffa8bebeb4173f57a0be82978a4d223c0c6c 100644 (file)
@@ -49,7 +49,7 @@ class Node(object):
         for rds in self.rdatasets:
             if len(rds) > 0:
                 s.write(rds.to_text(name, **kw))
-                s.write(u'\n')
+                s.write('\n')
         return s.getvalue()[:-1]
 
     def __repr__(self):
index 7f4339c0f01aea7d777bf19d8cca354ddc73028c..df08c944f20742fe3bc47efbed0956f6e6511ac6 100644 (file)
@@ -205,12 +205,12 @@ class Rdataset(dns.set.Set):
             # some dynamic updates, so we don't need to print out the TTL
             # (which is meaningless anyway).
             #
-            s.write(u'{}{}{} {}\n'.format(ntext, pad,
-                                          dns.rdataclass.to_text(rdclass),
-                                          dns.rdatatype.to_text(self.rdtype)))
+            s.write('{}{}{} {}\n'.format(ntext, pad,
+                                         dns.rdataclass.to_text(rdclass),
+                                         dns.rdatatype.to_text(self.rdtype)))
         else:
             for rd in self:
-                s.write(u'%s%s%d %s %s %s\n' %
+                s.write('%s%s%d %s %s %s\n' %
                         (ntext, pad, self.ttl, dns.rdataclass.to_text(rdclass),
                          dns.rdatatype.to_text(self.rdtype),
                          rd.to_text(origin=origin, relativize=relativize,
index 7c876b2d2ffc1c7375a8029075ddb138033ef0c7..81e13c27957bc4b8c7520145b1be16e337209d05 100644 (file)
@@ -50,13 +50,13 @@ class HIP(dns.rdata.Rdata):
     def to_text(self, origin=None, relativize=True, **kw):
         hit = binascii.hexlify(self.hit).decode()
         key = base64.b64encode(self.key).replace(b'\n', b'').decode()
-        text = u''
+        text = ''
         servers = []
         for server in self.servers:
             servers.append(server.choose_relativity(origin, relativize))
         if len(servers) > 0:
-            text += (u' ' + u' '.join((x.to_unicode() for x in servers)))
-        return u'%u %s %s%s' % (self.algorithm, hit, key, text)
+            text += (' ' + ' '.join((x.to_unicode() for x in servers)))
+        return '%u %s %s%s' % (self.algorithm, hit, key, text)
 
     @classmethod
     def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
index e33cc7c3be92de0f3947f7c8e3ed788007ba4781..95e02eb8ca81bf943552a3f414786e16026f6f09 100644 (file)
@@ -75,7 +75,7 @@ class NSEC3(dns.rdata.Rdata):
             salt = '-'
         else:
             salt = binascii.hexlify(self.salt).decode()
-        text = u''
+        text = ''
         for (window, bitmap) in self.windows:
             bits = []
             for (i, byte) in enumerate(bitmap):
@@ -83,9 +83,9 @@ class NSEC3(dns.rdata.Rdata):
                     if byte & (0x80 >> j):
                         bits.append(dns.rdatatype.to_text(window * 256 +
                                                           i * 8 + j))
-            text += (u' ' + u' '.join(bits))
-        return u'%u %u %u %s %s%s' % (self.algorithm, self.flags,
-                                      self.iterations, salt, next, text)
+            text += (' ' + ' '.join(bits))
+        return '%u %u %u %s %s%s' % (self.algorithm, self.flags,
+                                     self.iterations, salt, next, text)
 
     @classmethod
     def from_text(cls, rdclass, rdtype, tok, origin=None, relativize=True):
@@ -93,7 +93,7 @@ class NSEC3(dns.rdata.Rdata):
         flags = tok.get_uint8()
         iterations = tok.get_uint16()
         salt = tok.get_string()
-        if salt == u'-':
+        if salt == '-':
             salt = b''
         else:
             salt = binascii.unhexlify(salt.encode('ascii'))
index 3da8208b82c05e416a639adff771ee9e3d389109..9f552ad0cf53b2c134933cae4adefcd89576ec29 100644 (file)
@@ -506,7 +506,7 @@ class Zone(object):
 
         if nl is None:
             nl_b = os.linesep.encode(file_enc)  # binary mode, '\n' is not enough
-            nl = u'\n'
+            nl = '\n'
         elif isinstance(nl, str):
             nl_b = nl.encode(file_enc)
         else:
@@ -839,21 +839,21 @@ class _MasterReader(object):
         for i in range(start, stop + 1, step):
             # +1 because bind is inclusive and python is exclusive
 
-            if lsign == u'+':
+            if lsign == '+':
                 lindex = i + int(loffset)
-            elif lsign == u'-':
+            elif lsign == '-':
                 lindex = i - int(loffset)
 
-            if rsign == u'-':
+            if rsign == '-':
                 rindex = i - int(roffset)
-            elif rsign == u'+':
+            elif rsign == '+':
                 rindex = i + int(roffset)
 
             lzfindex = str(lindex).zfill(int(lwidth))
             rzfindex = str(rindex).zfill(int(rwidth))
 
-            name = lhs.replace(u'$%s' % (lmod), lzfindex)
-            rdata = rhs.replace(u'$%s' % (rmod), rzfindex)
+            name = lhs.replace('$%s' % (lmod), lzfindex)
+            rdata = rhs.replace('$%s' % (rmod), rzfindex)
 
             self.last_name = dns.name.from_text(name, self.current_origin)
             name = self.last_name
@@ -918,21 +918,21 @@ class _MasterReader(object):
                 elif token.is_comment():
                     self.tok.get_eol()
                     continue
-                elif token.value[0] == u'$':
+                elif token.value[0] == '$':
                     c = token.value.upper()
-                    if c == u'$TTL':
+                    if c == '$TTL':
                         token = self.tok.get()
                         if not token.is_identifier():
                             raise dns.exception.SyntaxError("bad $TTL")
                         self.default_ttl = dns.ttl.from_text(token.value)
                         self.default_ttl_known = True
                         self.tok.get_eol()
-                    elif c == u'$ORIGIN':
+                    elif c == '$ORIGIN':
                         self.current_origin = self.tok.get_name()
                         self.tok.get_eol()
                         if self.zone.origin is None:
                             self.zone.origin = self.current_origin
-                    elif c == u'$INCLUDE' and self.allow_include:
+                    elif c == '$INCLUDE' and self.allow_include:
                         token = self.tok.get()
                         filename = token.value
                         token = self.tok.get()
@@ -958,7 +958,7 @@ class _MasterReader(object):
                         self.tok = dns.tokenizer.Tokenizer(self.current_file,
                                                            filename)
                         self.current_origin = new_origin
-                    elif c == u'$GENERATE':
+                    elif c == '$GENERATE':
                         self._generate_line()
                     else:
                         raise dns.exception.SyntaxError(
index b3b47eb32aaf2c2fde28553c4e8ed59c990abbe1..45906663760cd1f18f1c21698a5b261a66eb495e 100644 (file)
@@ -60,7 +60,7 @@ class BugsTestCase(unittest.TestCase):
 
     def test_CAA_from_wire(self):
         rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.CAA,
-                                    u'0 issue "ca.example.net"')
+                                    '0 issue "ca.example.net"')
         f = BytesIO()
         rdata.to_wire(f)
         wire = f.getvalue()
index 54b0f31f5150c8062970fa2a0f47985c93d675a1..da576d903209061fb911483ca9bc16e2995dacc2 100644 (file)
@@ -650,38 +650,38 @@ class NameTestCase(unittest.TestCase):
         self.failUnlessRaises(dns.name.NoParent, bad)
 
     def testFromUnicode1(self):
-        n = dns.name.from_text(u'foo.bar')
+        n = dns.name.from_text('foo.bar')
         self.assertEqual(n.labels, (b'foo', b'bar', b''))
 
     def testFromUnicode2(self):
-        n = dns.name.from_text(u'foo\u1234bar.bar')
+        n = dns.name.from_text('foo\u1234bar.bar')
         self.assertEqual(n.labels, (b'xn--foobar-r5z', b'bar', b''))
 
     def testFromUnicodeAlternateDot1(self):
-        n = dns.name.from_text(u'foo\u3002bar')
+        n = dns.name.from_text('foo\u3002bar')
         self.assertEqual(n.labels, (b'foo', b'bar', b''))
 
     def testFromUnicodeAlternateDot2(self):
-        n = dns.name.from_text(u'foo\uff0ebar')
+        n = dns.name.from_text('foo\uff0ebar')
         self.assertEqual(n.labels, (b'foo', b'bar', b''))
 
     def testFromUnicodeAlternateDot3(self):
-        n = dns.name.from_text(u'foo\uff61bar')
+        n = dns.name.from_text('foo\uff61bar')
         self.assertEqual(n.labels, (b'foo', b'bar', b''))
 
     def testFromUnicodeIDNA2003Explicit(self):
-        t = u'Königsgäßchen'
+        t = 'Königsgäßchen'
         e = dns.name.from_unicode(t, idna_codec=dns.name.IDNA_2003)
         self.assertEqual(str(e), 'xn--knigsgsschen-lcb0w.')
 
     def testFromUnicodeIDNA2003Default(self):
-        t = u'Königsgäßchen'
+        t = 'Königsgäßchen'
         e = dns.name.from_unicode(t)
         self.assertEqual(str(e), 'xn--knigsgsschen-lcb0w.')
 
     def testFromUnicodeIDNA2008(self):
         if dns.name.have_idna_2008:
-            t = u'Königsgäßchen'
+            t = 'Königsgäßchen'
             def bad():
                 codec = dns.name.IDNA_2008_Strict
                 return dns.name.from_unicode(t, idna_codec=codec)
@@ -694,12 +694,12 @@ class NameTestCase(unittest.TestCase):
 
     def testFromUnicodeIDNA2008Mixed(self):
         # the IDN rules for names are very restrictive, disallowing
-        # practical names like u'_sip._tcp.Königsgäßchen'.  Dnspython
+        # practical names like '_sip._tcp.Königsgäßchen'.  Dnspython
         # has a "practical" mode which permits labels which are purely
         # ASCII to go straight through, and thus not invalid useful
         # things in the real world.
         if dns.name.have_idna_2008:
-            t = u'_sip._tcp.Königsgäßchen'
+            t = '_sip._tcp.Königsgäßchen'
             def bad1():
                 codec = dns.name.IDNA_2008_Strict
                 return dns.name.from_unicode(t, idna_codec=codec)
@@ -717,34 +717,34 @@ class NameTestCase(unittest.TestCase):
             self.assertEqual(str(e), '_sip._tcp.xn--knigsgchen-b4a3dun.')
 
     def testToUnicode1(self):
-        n = dns.name.from_text(u'foo.bar')
+        n = dns.name.from_text('foo.bar')
         s = n.to_unicode()
-        self.assertEqual(s, u'foo.bar.')
+        self.assertEqual(s, 'foo.bar.')
 
     def testToUnicode2(self):
-        n = dns.name.from_text(u'foo\u1234bar.bar')
+        n = dns.name.from_text('foo\u1234bar.bar')
         s = n.to_unicode()
-        self.assertEqual(s, u'foo\u1234bar.bar.')
+        self.assertEqual(s, 'foo\u1234bar.bar.')
 
     def testToUnicode3(self):
         n = dns.name.from_text('foo.bar')
         s = n.to_unicode()
-        self.assertEqual(s, u'foo.bar.')
+        self.assertEqual(s, 'foo.bar.')
 
     def testToUnicode4(self):
         if dns.name.have_idna_2008:
-            n = dns.name.from_text(u'ドメイン.テスト',
+            n = dns.name.from_text('ドメイン.テスト',
                                    idna_codec=dns.name.IDNA_2008)
             s = n.to_unicode()
             self.assertEqual(str(n), 'xn--eckwd4c7c.xn--zckzah.')
-            self.assertEqual(s, u'ドメイン.テスト.')
+            self.assertEqual(s, 'ドメイン.テスト.')
 
     def testDefaultDecodeIsJustPunycode(self):
         # groß.com. in IDNA2008 form, pre-encoded.
         n = dns.name.from_text('xn--gro-7ka.com')
         # output using default codec which just decodes the punycode and
         # doesn't test for IDNA2003 or IDNA2008.
-        self.assertEqual(n.to_unicode(), u'groß.com.')
+        self.assertEqual(n.to_unicode(), 'groß.com.')
 
     def testStrictINDA2003Decode(self):
         # groß.com. in IDNA2008 form, pre-encoded.
index 8a6636c7f38306ba76aa50dafb22cfd4c8cfef7a..fc7e0e20a5cadbc9a68ea7f41aeae43ce5ded6e3 100644 (file)
@@ -29,11 +29,6 @@ class TokenizerTestCase(unittest.TestCase):
         token = tok.get()
         self.failUnless(token == Token(dns.tokenizer.IDENTIFIER, 'foo'))
 
-    def testUnicode(self):
-        tok = dns.tokenizer.Tokenizer(u'foo')
-        token = tok.get()
-        self.failUnless(token == Token(dns.tokenizer.IDENTIFIER, 'foo'))
-
     def testQuotedString1(self):
         tok = dns.tokenizer.Tokenizer(r'"foo"')
         token = tok.get()
index 71b87515a3684ce2f8bcec8255d805f21cb40ff5..65655ef83d073c18d6363c6573ab61a36bbb1fbe 100644 (file)
@@ -236,7 +236,7 @@ class ZoneTestCase(unittest.TestCase):
         names.sort()
         for n in names:
             f.write(z[n].to_text(n))
-            f.write(u'\n')
+            f.write('\n')
         self.assertEqual(f.getvalue(), example_text_output)
 
     def testTorture1(self): # type: () -> None