r47224 - merging forward
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Wed, 13 Apr 2016 23:15:35 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Wed Apr 13 23:15:30 2016
New Revision: 47224
Added:
branches/t-names-authority-py3-8259-3/twisted/names/topfiles/8259.feature
Modified:
branches/t-names-authority-py3-8259-3/twisted/names/authority.py
branches/t-names-authority-py3-8259-3/twisted/names/dns.py
branches/t-names-authority-py3-8259-3/twisted/names/secondary.py
branches/t-names-authority-py3-8259-3/twisted/names/test/test_examples.py
branches/t-names-authority-py3-8259-3/twisted/names/test/test_names.py
branches/t-names-authority-py3-8259-3/twisted/python/dist3.py
Log:
merging forward
Modified: branches/t-names-authority-py3-8259-3/twisted/names/authority.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/names/authority.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/names/authority.py Wed Apr 13 23:15:30 2016
@@ -6,15 +6,16 @@
Authoritative resolvers.
"""
+from __future__ import absolute_import, division
+
import os
import time
-from twisted.names import dns, error
+from twisted.names import dns, error, common
from twisted.internet import defer
from twisted.python import failure
from twisted.python.compat import execfile
-import common
def getSerial(filename = '/tmp/twisted-names.serial'):
"""Return a monotonically increasing (across program runs) integer.
@@ -24,25 +25,21 @@
"""
serial = time.strftime('%Y%m%d')
- o = os.umask(0177)
+ o = os.umask(0o177)
try:
if not os.path.exists(filename):
- f = file(filename, 'w')
- f.write(serial + ' 0')
- f.close()
+ with open(filename, 'w') as f:
+ f.write(serial + ' 0')
finally:
os.umask(o)
- serialFile = file(filename, 'r')
- lastSerial, ID = serialFile.readline().split()
+ with open(filename, 'r') as serialFile:
+ lastSerial, ID = serialFile.readline().split()
+
ID = (lastSerial == serial) and (int(ID) + 1) or 0
- serialFile.close()
- serialFile = file(filename, 'w')
- serialFile.write('%s %d' % (serial, ID))
- serialFile.close()
- serial = serial + ('%02d' % (ID,))
- return serial
+ with open(filename, 'w') as serialFile:
+ serialFile.write('%s %d' % (serial, ID))
#class LookupCacherMixin(object):
# _cache = None
@@ -58,6 +55,8 @@
# r = self._meth(name, cls, type, timeout)
# self._cache[(name, cls, type)] = r
# return r
+ serial = serial + ('%02d' % (ID,))
+ return serial
@@ -67,8 +66,12 @@
@ivar _ADDITIONAL_PROCESSING_TYPES: Record types for which additional
processing will be done.
+
@ivar _ADDRESS_TYPES: Record types which are useful for inclusion in the
additional section generated during additional processing.
+
+ @ivar soa: A 2-tuple containing the SOA domain name as a L{bytes} and a
+ L{dns.Record_SOA}.
"""
# See https://twistedmatrix.com/trac/ticket/6650
_ADDITIONAL_PROCESSING_TYPES = (dns.CNAME, dns.MX, dns.NS)
@@ -244,7 +247,7 @@
g, l = self.setupConfigNamespace(), {}
execfile(filename, g, l)
if not l.has_key('zone'):
- raise ValueError, "No zone defined in " + filename
+ raise ValueError("No zone defined in " + filename)
self.records = {}
for rr in l['zone']:
@@ -272,7 +275,9 @@
def loadFile(self, filename):
self.origin = os.path.basename(filename) + '.' # XXX - this might suck
- lines = open(filename).readlines()
+
+ with open(filename, 'rb') as f:
+ lines = f.readlines()
lines = self.stripComments(lines)
lines = self.collapseContinuations(lines)
self.parseLines(lines)
@@ -337,7 +342,7 @@
if f:
f(ttl, type, domain, rdata)
else:
- raise NotImplementedError, "Record class %r not supported" % cls
+ raise NotImplementedError("Record class %r not supported" % cls)
def class_IN(self, ttl, type, domain, rdata):
@@ -347,11 +352,11 @@
r.ttl = ttl
self.records.setdefault(domain.lower(), []).append(r)
- print 'Adding IN Record', domain, ttl, r
+ print('Adding IN Record', domain, ttl, r)
if type == 'SOA':
self.soa = (domain, r)
else:
- raise NotImplementedError, "Record type %r not supported" % type
+ raise NotImplementedError("Record type %r not supported" % type)
#
Modified: branches/t-names-authority-py3-8259-3/twisted/names/dns.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/names/dns.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/names/dns.py Wed Apr 13 23:15:30 2016
@@ -212,7 +212,7 @@
"""
Split a domain name into its constituent labels.
- @type name: C{str}
+ @type name: C{bytes}
@param name: A fully qualified domain name (with or without a
trailing dot).
@@ -270,7 +270,8 @@
(years). For example: C{"3S"} indicates an interval of three seconds;
C{"5D"} indicates an interval of five days. Alternatively, C{s} may be
any non-string and it will be returned unmodified.
- @type s: text string (C{str}) for parsing; anything else for passthrough.
+ @type s: text string (L{bytes} or L{unicode}) for parsing; anything else
+ for passthrough.
@return: an C{int} giving the interval represented by the string C{s}, or
whatever C{s} is if it is not a string.
@@ -279,6 +280,9 @@
('S', 1), ('M', 60), ('H', 60 * 60), ('D', 60 * 60 * 24),
('W', 60 * 60 * 24 * 7), ('Y', 60 * 60 * 24 * 365)
)
+ if _PY3 and isinstance(s, bytes):
+ s = s.decode('ascii')
+
if isinstance(s, str):
s = s.upper().strip()
for (suff, mult) in suffixes:
@@ -408,6 +412,10 @@
@type name: C{bytes}
"""
def __init__(self, name=b''):
+ """
+ @param name: A name.
+ @type name: L{unicode} or L{bytes}
+ """
if isinstance(name, unicode):
name = name.encode('idna')
if not isinstance(name, bytes):
@@ -520,8 +528,13 @@
Represent a single DNS query.
@ivar name: The name about which this query is requesting information.
+ @type name: L{Name}
+
@ivar type: The query type.
+ @type type: L{int}
+
@ivar cls: The query class.
+ @type cls: L{int}
"""
name = None
type = None
@@ -529,8 +542,8 @@
def __init__(self, name=b'', type=A, cls=IN):
"""
- @type name: C{bytes}
- @param name: The name about which to request information.
+ @type name: L{bytes} or L{unicode}
+ @param name: See L{Query.name}
@type type: C{int}
@param type: The query type.
@@ -826,10 +839,17 @@
@cvar fmt: C{str} specifying the byte format of an RR.
@ivar name: The name about which this reply contains information.
+ @type name: L{Name}
+
@ivar type: The query type of the original request.
+ @type type: L{int}
+
@ivar cls: The query class of the original request.
+
@ivar ttl: The time-to-live for this record.
- @ivar payload: An object that implements the IEncodable interface
+ @type ttl: L{int}
+
+ @ivar payload: An object that implements the L{IEncodable} interface
@ivar auth: A C{bool} indicating whether this C{RRHeader} was parsed from an
authoritative message.
@@ -847,10 +867,11 @@
cachedResponse = None
- def __init__(self, name=b'', type=A, cls=IN, ttl=0, payload=None, auth=False):
+ def __init__(self, name=b'', type=A, cls=IN, ttl=0, payload=None,
+ auth=False):
"""
- @type name: C{bytes}
- @param name: The name about which this reply contains information.
+ @type name: C{bytes} or L{unicode}
+ @param name: See L{RRHeader.name}
@type type: C{int}
@param type: The query type.
@@ -932,6 +953,10 @@
name = None
def __init__(self, name=b'', ttl=None):
+ """
+ @param name: See L{SimpleRecord.name}
+ @type name: L{bytes} or L{unicode}
+ """
self.name = Name(name)
self.ttl = str2time(ttl)
@@ -1057,7 +1082,7 @@
"""
An IPv4 host address.
- @type address: C{str}
+ @type address: C{bytes}
@ivar address: The packed network-order representation of the IPv4 address
associated with this record.
@@ -1071,6 +1096,14 @@
address = None
def __init__(self, address='0.0.0.0', ttl=None):
+ """
+ @type address: L{bytes} or L{unicode}
+ @param address: The IPv4 address associated with this record, in
+ quad-dotted notation.
+ """
+ if _PY3 and isinstance(address, bytes):
+ address = address.decode('idna')
+
address = socket.inet_aton(address)
self.address = address
self.ttl = str2time(ttl)
@@ -1146,6 +1179,13 @@
def __init__(self, mname=b'', rname=b'', serial=0, refresh=0, retry=0,
expire=0, minimum=0, ttl=None):
+ """
+ @param mname: See L{Record_SOA.mname}
+ @type mname: L{bytes} or L{unicode}
+
+ @param rname: See L{Record_SOA.rname}
+ @type rname: L{bytes} or L{unicode}
+ """
self.mname, self.rname = Name(mname), Name(rname)
self.serial, self.refresh = str2time(serial), str2time(refresh)
self.minimum, self.expire = str2time(minimum), str2time(expire)
@@ -1223,7 +1263,7 @@
This record type is obsolete. See L{Record_SRV}.
- @type address: C{str}
+ @type address: C{bytes}
@ivar address: The packed network-order representation of the IPv4 address
associated with this record.
@@ -1231,7 +1271,7 @@
@ivar protocol: The 8 bit IP protocol number for which this service map is
relevant.
- @type map: C{str}
+ @type map: L{bytes}
@ivar map: A bitvector indicating the services available at the specified
address.
@@ -1247,7 +1287,15 @@
_address = property(lambda self: socket.inet_ntoa(self.address))
- def __init__(self, address='0.0.0.0', protocol=0, map='', ttl=None):
+ def __init__(self, address='0.0.0.0', protocol=0, map=b'', ttl=None):
+ """
+ @type address: L{bytes} or L{unicode}
+ @param address: The IPv4 address associated with this record, in
+ quad-dotted notation.
+ """
+ if _PY3 and isinstance(address, bytes):
+ address = address.decode('idna')
+
self.address = socket.inet_aton(address)
self.protocol, self.map = protocol, map
self.ttl = str2time(ttl)
@@ -1275,7 +1323,7 @@
"""
An IPv6 host address.
- @type address: C{str}
+ @type address: L{bytes}
@ivar address: The packed network-order representation of the IPv6 address
associated with this record.
@@ -1294,6 +1342,13 @@
_address = property(lambda self: socket.inet_ntop(AF_INET6, self.address))
def __init__(self, address='::', ttl=None):
+ """
+ @type address: L{bytes} or L{unicode}
+ @param address: The IPv6 address for this host, in RFC 2373 format.
+ """
+ if _PY3 and isinstance(address, bytes):
+ address = address.decode('idna')
+
self.address = socket.inet_pton(AF_INET6, address)
self.ttl = str2time(ttl)
@@ -1321,7 +1376,7 @@
@type prefixLen: C{int}
@ivar prefixLen: The length of the suffix.
- @type suffix: C{str}
+ @type suffix: C{bytes}
@ivar suffix: An IPv6 address suffix in network order.
@type prefix: L{Name}
@@ -1348,6 +1403,16 @@
_suffix = property(lambda self: socket.inet_ntop(AF_INET6, self.suffix))
def __init__(self, prefixLen=0, suffix='::', prefix=b'', ttl=None):
+ """
+ @param suffix: An IPv6 address suffix in in RFC 2373 format.
+ @type suffix: L{bytes} or L{unicode}
+
+ @param prefix: An IPv6 address prefix for other A6 records.
+ @type prefix: L{bytes} or L{unicode}
+ """
+ if _PY3 and isinstance(suffix, bytes):
+ suffix = suffix.decode('idna')
+
self.prefixLen = prefixLen
self.suffix = socket.inet_pton(AF_INET6, suffix)
self.prefix = Name(prefix)
@@ -1437,6 +1502,10 @@
showAttributes = ('priority', 'weight', ('target', 'target', '%s'), 'port', 'ttl')
def __init__(self, priority=0, weight=0, port=0, target=b'', ttl=None):
+ """
+ @param target: See L{Record_SRV.target}
+ @type target: L{bytes} or L{unicode}
+ """
self.priority = int(priority)
self.weight = int(weight)
self.port = int(port)
@@ -1517,8 +1586,12 @@
('service', 'service', '%s'), ('regexp', 'regexp', '%s'),
('replacement', 'replacement', '%s'), 'ttl')
- def __init__(self, order=0, preference=0, flags=b'', service=b'', regexp=b'',
- replacement=b'', ttl=None):
+ def __init__(self, order=0, preference=0, flags=b'', service=b'',
+ regexp=b'', replacement=b'', ttl=None):
+ """
+ @param replacement: See L{Record_NAPTR.replacement}
+ @type replacement: L{bytes} or L{unicode}
+ """
self.order = int(order)
self.preference = int(preference)
self.flags = Charstr(flags)
@@ -1585,6 +1658,10 @@
showAttributes = ('subtype', ('hostname', 'hostname', '%s'), 'ttl')
def __init__(self, subtype=0, hostname=b'', ttl=None):
+ """
+ @param hostname: See L{Record_AFSDB.hostname}
+ @type hostname: L{bytes} or L{unicode}
+ """
self.subtype = int(subtype)
self.hostname = Name(hostname)
self.ttl = str2time(ttl)
@@ -1632,6 +1709,13 @@
showAttributes = (('mbox', 'mbox', '%s'), ('txt', 'txt', '%s'), 'ttl')
def __init__(self, mbox=b'', txt=b'', ttl=None):
+ """
+ @param mbox: See L{Record_RP.mbox}.
+ @type mbox: L{bytes} or L{unicode}
+
+ @param txt: See L{Record_RP.txt}
+ @type txt: L{bytes} or L{unicode}
+ """
self.mbox = Name(mbox)
self.txt = Name(txt)
self.ttl = str2time(ttl)
@@ -1659,10 +1743,10 @@
"""
Host information.
- @type cpu: C{str}
+ @type cpu: L{bytes}
@ivar cpu: Specifies the CPU type.
- @type os: C{str}
+ @type os: L{bytes}
@ivar os: Specifies the OS.
@type ttl: C{int}
@@ -1675,7 +1759,7 @@
showAttributes = (('cpu', _nicebytes), ('os', _nicebytes), 'ttl')
compareAttributes = ('cpu', 'os', 'ttl')
- def __init__(self, cpu='', os='', ttl=None):
+ def __init__(self, cpu=b'', os=b'', ttl=None):
self.cpu, self.os = cpu, os
self.ttl = str2time(ttl)
@@ -1739,6 +1823,13 @@
'ttl')
def __init__(self, rmailbx=b'', emailbx=b'', ttl=None):
+ """
+ @param rmailbx: See L{Record_MINFO.rmailbx}.
+ @type rmailbx: L{bytes} or L{unicode}
+
+ @param emailbx: See L{Record_MINFO.rmailbx}.
+ @type emailbx: L{bytes} or L{unicode}
+ """
self.rmailbx, self.emailbx = Name(rmailbx), Name(emailbx)
self.ttl = str2time(ttl)
@@ -1783,7 +1874,12 @@
showAttributes = ('preference', ('name', 'name', '%s'), 'ttl')
def __init__(self, preference=0, name=b'', ttl=None, **kwargs):
- self.preference, self.name = int(preference), Name(kwargs.get('exchange', name))
+ """
+ @param name: See L{Record_MX.name}.
+ @type name: L{bytes} or L{unicode}
+ """
+ self.preference = int(preference)
+ self.name = Name(kwargs.get('exchange', name))
self.ttl = str2time(ttl)
def encode(self, strio, compDict = None):
@@ -1900,7 +1996,7 @@
Structurally, freeform text. Semantically, a policy definition, formatted
as defined in U{rfc 4408<http://www.faqs.org/rfcs/rfc4408.html>}.
- @type data: C{list} of C{str}
+ @type data: C{list} of C{bytes}
@ivar data: Freeform text which makes up this record.
@type ttl: C{int}
Modified: branches/t-names-authority-py3-8259-3/twisted/names/secondary.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/names/secondary.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/names/secondary.py Wed Apr 13 23:15:30 2016
@@ -2,6 +2,8 @@
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
+from __future__ import absolute_import, division
+
__all__ = ['SecondaryAuthority', 'SecondaryAuthorityService']
from twisted.internet import task, defer
@@ -23,9 +25,11 @@
"""
@param primary: The IP address of the server from which to perform
zone transfers.
+ @type primary: L{str}
@param domains: A sequence of domain names for which to perform
zone transfers.
+ @type domains: L{list} of L{bytes}
"""
self.primary = primary
self.domains = [SecondaryAuthority(primary, d) for d in domains]
@@ -43,7 +47,7 @@
C{int} giving a port number. Together, these define where zone
transfers will be attempted from.
- @param domain: A C{str} giving the domain to transfer.
+ @param domain: A C{bytes} giving the domain to transfer.
@return: A new instance of L{SecondaryAuthorityService}.
"""
@@ -98,6 +102,11 @@
_reactor = None
def __init__(self, primaryIP, domain):
+ """
+ @param domain: The domain for which this will be the secondary
+ authority.
+ @type domain: L{bytes}
+ """
# Yep. Skip over FileAuthority.__init__. This is a hack until we have
# a good composition-based API for the complicated DNS record lookup
# logic we want to share.
@@ -110,7 +119,7 @@
def fromServerAddressAndDomain(cls, serverAddress, domain):
"""
Construct a new L{SecondaryAuthority} from a tuple giving a server
- address and a C{str} giving the name of a domain for which this is an
+ address and a C{bytes} giving the name of a domain for which this is an
authority.
@param serverAddress: A two-tuple, the first element of which is a
@@ -118,7 +127,7 @@
C{int} giving a port number. Together, these define where zone
transfers will be attempted from.
- @param domain: A C{str} giving the domain to transfer.
+ @param domain: A C{bytes} giving the domain to transfer.
@return: A new instance of L{SecondaryAuthority}.
"""
Modified: branches/t-names-authority-py3-8259-3/twisted/names/test/test_examples.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/names/test/test_examples.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/names/test/test_examples.py Wed Apr 13 23:15:30 2016
@@ -5,12 +5,13 @@
Tests for L{twisted.names} example scripts.
"""
+from __future__ import absolute_import, division
+
import sys
-from StringIO import StringIO
from twisted.python.filepath import FilePath
from twisted.trial.unittest import SkipTest, TestCase
-
+from twisted.python.compat import NativeStringIO
class ExampleTestBase(object):
@@ -37,9 +38,9 @@
self.originalPath = sys.path[:]
self.originalModules = sys.modules.copy()
- self.fakeErr = StringIO()
+ self.fakeErr = NativeStringIO()
self.patch(sys, 'stderr', self.fakeErr)
- self.fakeOut = StringIO()
+ self.fakeOut = NativeStringIO()
self.patch(sys, 'stdout', self.fakeOut)
# Get documentation root
@@ -81,7 +82,7 @@
"""
self.assertEqual(
self.examplePath.open().readline().rstrip(),
- '#!/usr/bin/env python')
+ b'#!/usr/bin/env python')
def test_usageConsistency(self):
Modified: branches/t-names-authority-py3-8259-3/twisted/names/test/test_names.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/names/test/test_names.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/names/test/test_names.py Wed Apr 13 23:15:30 2016
@@ -5,8 +5,13 @@
Test cases for twisted.names.
"""
-import socket, operator, copy
-from StringIO import StringIO
+from __future__ import absolute_import, division
+
+import socket
+import operator
+import copy
+
+from io import BytesIO
from functools import partial, reduce
from struct import pack
@@ -34,8 +39,8 @@
soa_record = dns.Record_SOA(
- mname = 'test-domain.com',
- rname = 'root.test-domain.com',
+ mname = b'test-domain.com',
+ rname = u'root.test-domain.com',
serial = 100,
refresh = 1234,
minimum = 7654,
@@ -45,8 +50,8 @@
)
reverse_soa = dns.Record_SOA(
- mname = '93.84.28.in-addr.arpa',
- rname = '93.84.28.in-addr.arpa',
+ mname = b'93.84.28.in-addr.arpa',
+ rname = b'93.84.28.in-addr.arpa',
serial = 120,
refresh = 54321,
minimum = 382,
@@ -56,8 +61,8 @@
)
my_soa = dns.Record_SOA(
- mname = 'my-domain.com',
- rname = 'postmaster.test-domain.com',
+ mname = u'my-domain.com',
+ rname = b'postmaster.test-domain.com',
serial = 130,
refresh = 12345,
minimum = 1,
@@ -66,61 +71,63 @@
)
test_domain_com = NoFileAuthority(
- soa = ('test-domain.com', soa_record),
+ soa = (b'test-domain.com', soa_record),
records = {
- 'test-domain.com': [
+ b'test-domain.com': [
soa_record,
- dns.Record_A('127.0.0.1'),
- dns.Record_NS('39.28.189.39'),
- dns.Record_SPF('v=spf1 mx/30 mx:example.org/30 -all'),
- dns.Record_SPF('v=spf1 +mx a:\0colo', '.example.com/28 -all not valid'),
- dns.Record_MX(10, 'host.test-domain.com'),
- dns.Record_HINFO(os='Linux', cpu='A Fast One, Dontcha know'),
- dns.Record_CNAME('canonical.name.com'),
- dns.Record_MB('mailbox.test-domain.com'),
- dns.Record_MG('mail.group.someplace'),
- dns.Record_TXT('A First piece of Text', 'a SecoNd piece'),
- dns.Record_A6(0, 'ABCD::4321', ''),
- dns.Record_A6(12, '0:0069::0', 'some.network.tld'),
- dns.Record_A6(8, '0:5634:1294:AFCB:56AC:48EF:34C3:01FF', 'tra.la.la.net'),
- dns.Record_TXT('Some more text, haha! Yes. \0 Still here?'),
- dns.Record_MR('mail.redirect.or.whatever'),
- dns.Record_MINFO(rmailbx='r mail box', emailbx='e mail box'),
- dns.Record_AFSDB(subtype=1, hostname='afsdb.test-domain.com'),
- dns.Record_RP(mbox='whatever.i.dunno', txt='some.more.text'),
- dns.Record_WKS('12.54.78.12', socket.IPPROTO_TCP,
- '\x12\x01\x16\xfe\xc1\x00\x01'),
- dns.Record_NAPTR(100, 10, "u", "sip+E2U",
- "!^.*$!sip:[email protected]!"),
- dns.Record_AAAA('AF43:5634:1294:AFCB:56AC:48EF:34C3:01FF')],
- 'http.tcp.test-domain.com': [
- dns.Record_SRV(257, 16383, 43690, 'some.other.place.fool')
+ dns.Record_A(b'127.0.0.1'),
+ dns.Record_NS(b'39.28.189.39'),
+ dns.Record_SPF(b'v=spf1 mx/30 mx:example.org/30 -all'),
+ dns.Record_SPF(b'v=spf1 +mx a:\0colo',
+ b'.example.com/28 -all not valid'),
+ dns.Record_MX(10, u'host.test-domain.com'),
+ dns.Record_HINFO(os=b'Linux', cpu=b'A Fast One, Dontcha know'),
+ dns.Record_CNAME(b'canonical.name.com'),
+ dns.Record_MB(b'mailbox.test-domain.com'),
+ dns.Record_MG(b'mail.group.someplace'),
+ dns.Record_TXT(b'A First piece of Text', b'a SecoNd piece'),
+ dns.Record_A6(0, b'ABCD::4321', b''),
+ dns.Record_A6(12, b'0:0069::0', b'some.network.tld'),
+ dns.Record_A6(8, b'0:5634:1294:AFCB:56AC:48EF:34C3:01FF',
+ b'tra.la.la.net'),
+ dns.Record_TXT(b'Some more text, haha! Yes. \0 Still here?'),
+ dns.Record_MR(b'mail.redirect.or.whatever'),
+ dns.Record_MINFO(rmailbx=b'r mail box', emailbx=b'e mail box'),
+ dns.Record_AFSDB(subtype=1, hostname=b'afsdb.test-domain.com'),
+ dns.Record_RP(mbox=b'whatever.i.dunno', txt=b'some.more.text'),
+ dns.Record_WKS(b'12.54.78.12', socket.IPPROTO_TCP,
+ b'\x12\x01\x16\xfe\xc1\x00\x01'),
+ dns.Record_NAPTR(100, 10, b"u", b"sip+E2U",
+ b"!^.*$!sip:[email protected]!"),
+ dns.Record_AAAA(b'AF43:5634:1294:AFCB:56AC:48EF:34C3:01FF')],
+ b'http.tcp.test-domain.com': [
+ dns.Record_SRV(257, 16383, 43690, b'some.other.place.fool')
],
- 'host.test-domain.com': [
- dns.Record_A('123.242.1.5'),
- dns.Record_A('0.255.0.255'),
+ b'host.test-domain.com': [
+ dns.Record_A(b'123.242.1.5'),
+ dns.Record_A(b'0.255.0.255'),
],
- 'host-two.test-domain.com': [
+ b'host-two.test-domain.com': [
#
# Python bug
# dns.Record_A('255.255.255.255'),
#
- dns.Record_A('255.255.255.254'),
- dns.Record_A('0.0.0.0')
+ dns.Record_A(b'255.255.255.254'),
+ dns.Record_A(b'0.0.0.0')
],
- 'cname.test-domain.com': [
- dns.Record_CNAME('test-domain.com')
+ b'cname.test-domain.com': [
+ dns.Record_CNAME(b'test-domain.com')
],
- 'anothertest-domain.com': [
- dns.Record_A('1.2.3.4')],
+ b'anothertest-domain.com': [
+ dns.Record_A(b'1.2.3.4')],
}
)
reverse_domain = NoFileAuthority(
- soa = ('93.84.28.in-addr.arpa', reverse_soa),
+ soa = (b'93.84.28.in-addr.arpa', reverse_soa),
records = {
- '123.93.84.28.in-addr.arpa': [
- dns.Record_PTR('test.host-reverse.lookup.com'),
+ b'123.93.84.28.in-addr.arpa': [
+ dns.Record_PTR(b'test.host-reverse.lookup.com'),
reverse_soa
]
}
@@ -128,14 +135,15 @@
my_domain_com = NoFileAuthority(
- soa = ('my-domain.com', my_soa),
+ soa = (b'my-domain.com', my_soa),
records = {
- 'my-domain.com': [
+ b'my-domain.com': [
my_soa,
- dns.Record_A('1.2.3.4', ttl='1S'),
- dns.Record_NS('ns1.domain', ttl='2M'),
- dns.Record_NS('ns2.domain', ttl='3H'),
- dns.Record_SRV(257, 16383, 43690, 'some.other.place.fool', ttl='4D')
+ dns.Record_A(b'1.2.3.4', ttl='1S'),
+ dns.Record_NS(b'ns1.domain', ttl=b'2M'),
+ dns.Record_NS(b'ns2.domain', ttl='3H'),
+ dns.Record_SRV(257, 16383, 43690, b'some.other.place.fool',
+ ttl='4D')
]
}
)
@@ -224,7 +232,8 @@
"""Test DNS 'A' record queries with multiple answers"""
return self.namesTest(
self.resolver.lookupAddress('host.test-domain.com'),
- [dns.Record_A('123.242.1.5', ttl=19283784), dns.Record_A('0.255.0.255', ttl=19283784)]
+ [dns.Record_A('123.242.1.5', ttl=19283784),
+ dns.Record_A('0.255.0.255', ttl=19283784)]
)
@@ -268,7 +277,8 @@
"""Test DNS 'HINFO' record queries"""
return self.namesTest(
self.resolver.lookupHostInfo('test-domain.com'),
- [dns.Record_HINFO(os='Linux', cpu='A Fast One, Dontcha know', ttl=19283784)]
+ [dns.Record_HINFO(os=b'Linux', cpu=b'A Fast One, Dontcha know',
+ ttl=19283784)]
)
def test_PTR(self):
@@ -345,8 +355,10 @@
"""Test DNS 'TXT' record queries"""
return self.namesTest(
self.resolver.lookupText('test-domain.com'),
- [dns.Record_TXT('A First piece of Text', 'a SecoNd piece', ttl=19283784),
- dns.Record_TXT('Some more text, haha! Yes. \0 Still here?', ttl=19283784)]
+ [dns.Record_TXT(b'A First piece of Text', b'a SecoNd piece',
+ ttl=19283784),
+ dns.Record_TXT(b'Some more text, haha! Yes. \0 Still here?',
+ ttl=19283784)]
)
@@ -356,8 +368,10 @@
"""
return self.namesTest(
self.resolver.lookupSenderPolicy('test-domain.com'),
- [dns.Record_SPF('v=spf1 mx/30 mx:example.org/30 -all', ttl=19283784),
- dns.Record_SPF('v=spf1 +mx a:\0colo', '.example.com/28 -all not valid', ttl=19283784)]
+ [dns.Record_SPF(b'v=spf1 mx/30 mx:example.org/30 -all',
+ ttl=19283784),
+ dns.Record_SPF(b'v=spf1 +mx a:\0colo',
+ b'.example.com/28 -all not valid', ttl=19283784)]
)
@@ -365,7 +379,8 @@
"""Test DNS 'WKS' record queries"""
return self.namesTest(
self.resolver.lookupWellKnownServices('test-domain.com'),
- [dns.Record_WKS('12.54.78.12', socket.IPPROTO_TCP, '\x12\x01\x16\xfe\xc1\x00\x01', ttl=19283784)]
+ [dns.Record_WKS('12.54.78.12', socket.IPPROTO_TCP,
+ b'\x12\x01\x16\xfe\xc1\x00\x01', ttl=19283784)]
)
@@ -428,8 +443,8 @@
"""
return self.namesTest(
self.resolver.lookupNamingAuthorityPointer('test-domain.com'),
- [dns.Record_NAPTR(100, 10, "u", "sip+E2U",
- "!^.*$!sip:[email protected]!",
+ [dns.Record_NAPTR(100, 10, b"u", b"sip+E2U",
+ b"!^.*$!sip:[email protected]!",
ttl=19283784)])
@@ -510,7 +525,7 @@
def test_empty(self):
resolvConf = self.mktemp()
- fObj = file(resolvConf, 'w')
+ fObj = open(resolvConf, 'w')
fObj.close()
r = client.Resolver(resolv=resolvConf)
self.assertEqual(r.dynServers, [('127.0.0.1', 53)])
@@ -533,7 +548,7 @@
nothing to do with the zone example.com.
"""
testDomain = test_domain_com
- testDomainName = 'nonexistent.prefix-' + testDomain.soa[0]
+ testDomainName = b'nonexistent.prefix-' + testDomain.soa[0]
f = self.failureResultOf(testDomain.lookupAddress(testDomainName))
self.assertIsInstance(f.value, DomainError)
@@ -593,7 +608,7 @@
def test_referral(self):
"""
When an I{NS} record is found for a child zone, it is included in the
- authority section of the response. It is marked as non-authoritative if
+ authority section of the response. It is marked as non-authoritative if
the authority is not also authoritative for the child zone (RFC 2181,
section 6.1).
"""
@@ -667,7 +682,8 @@
@param computed: A L{list} of L{RRHeader} instances giving the records
computed by the scenario under test.
- @raise self.failureException: If the two collections of records disagree.
+ @raise self.failureException: If the two collections of records
+ disagree.
"""
# RRHeader instances aren't inherently ordered. Impose an ordering
# that's good enough for the purposes of these tests - in which we
@@ -969,7 +985,7 @@
msg = Message()
# DNSProtocol.writeMessage length encodes the message by prepending a
# 2 byte message length to the buffered value.
- msg.decode(StringIO(transport.value()[2:]))
+ msg.decode(BytesIO(transport.value()[2:]))
self.assertEqual(
[dns.Query('example.com', dns.AXFR, dns.IN)], msg.queries)
@@ -981,7 +997,7 @@
with the I{A} records the authority has cached from the primary.
"""
secondary = SecondaryAuthority.fromServerAddressAndDomain(
- (b'192.168.1.2', 1234), b'example.com')
+ ('192.168.1.2', 1234), b'example.com')
secondary._reactor = reactor = MemoryReactorClock()
secondary.transfer()
@@ -993,7 +1009,7 @@
proto.makeConnection(transport)
query = Message(answer=1, auth=1)
- query.decode(StringIO(transport.value()[2:]))
+ query.decode(BytesIO(transport.value()[2:]))
# Generate a response with some data we can check.
soa = Record_SOA(
Modified: branches/t-names-authority-py3-8259-3/twisted/python/dist3.py
==============================================================================
--- branches/t-names-authority-py3-8259-3/twisted/python/dist3.py (original)
+++ branches/t-names-authority-py3-8259-3/twisted/python/dist3.py Wed Apr 13 23:15:30 2016
@@ -124,6 +124,8 @@
"twisted.logger.test.__init__",
"twisted.names.__init__",
"twisted.names._rfc1982",
+ "twisted.names.authority",
+ "twisted.names.secondary",
"twisted.names.cache",
"twisted.names.client",
"twisted.names.common",
@@ -331,6 +333,8 @@
"twisted.names.test.test_rfc1982",
"twisted.names.test.test_server",
"twisted.names.test.test_util",
+ "twisted.names.test.test_names",
+ "twisted.names.test.test_examples",
"twisted.persisted.test.test_styles",
"twisted.positioning.test.test_base",
"twisted.positioning.test.test_nmea",