r47125 - Apply 8259.patch.
adiroiban-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Thu, 31 Mar 2016 08:54:19 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: adiroiban
Date: Thu Mar 31 08:54:14 2016
New Revision: 47125
Added:
branches/t-names-authority-py3-8259/twisted/names/topfiles/8259.feature
Modified:
branches/t-names-authority-py3-8259/twisted/names/authority.py
branches/t-names-authority-py3-8259/twisted/names/dns.py
branches/t-names-authority-py3-8259/twisted/names/secondary.py
branches/t-names-authority-py3-8259/twisted/names/test/test_examples.py
branches/t-names-authority-py3-8259/twisted/names/test/test_names.py
branches/t-names-authority-py3-8259/twisted/python/dist3.py
Log:
Apply 8259.patch.
Modified: branches/t-names-authority-py3-8259/twisted/names/authority.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/names/authority.py (original)
+++ branches/t-names-authority-py3-8259/twisted/names/authority.py Thu Mar 31 08:54:14 2016
@@ -5,16 +5,16 @@
"""
Authoritative resolvers.
"""
+from __future__ import absolute_import
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,20 +24,20 @@
"""
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 = open(filename, 'w')
f.write(serial + ' 0')
f.close()
finally:
os.umask(o)
- serialFile = file(filename, 'r')
+ serialFile = open(filename, 'r')
lastSerial, ID = serialFile.readline().split()
ID = (lastSerial == serial) and (int(ID) + 1) or 0
serialFile.close()
- serialFile = file(filename, 'w')
+ serialFile = open(filename, 'w')
serialFile.write('%s %d' % (serial, ID))
serialFile.close()
serial = serial + ('%02d' % (ID,))
@@ -244,7 +244,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']:
@@ -337,7 +337,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 +347,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/twisted/names/dns.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/names/dns.py (original)
+++ branches/t-names-authority-py3-8259/twisted/names/dns.py Thu Mar 31 08:54:14 2016
@@ -1231,7 +1231,7 @@
@ivar protocol: The 8 bit IP protocol number for which this service map is
relevant.
- @type map: C{str}
+ @type map: C{bytestring}
@ivar map: A bitvector indicating the services available at the specified
address.
@@ -1659,10 +1659,10 @@
"""
Host information.
- @type cpu: C{str}
+ @type cpu: C{bytestring}
@ivar cpu: Specifies the CPU type.
- @type os: C{str}
+ @type os: C{bytestring}
@ivar os: Specifies the OS.
@type ttl: C{int}
Modified: branches/t-names-authority-py3-8259/twisted/names/secondary.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/names/secondary.py (original)
+++ branches/t-names-authority-py3-8259/twisted/names/secondary.py Thu Mar 31 08:54:14 2016
@@ -1,6 +1,7 @@
# -*- test-case-name: twisted.names.test.test_names -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
+from __future__ import absolute_import
__all__ = ['SecondaryAuthority', 'SecondaryAuthorityService']
Modified: branches/t-names-authority-py3-8259/twisted/names/test/test_examples.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/names/test/test_examples.py (original)
+++ branches/t-names-authority-py3-8259/twisted/names/test/test_examples.py Thu Mar 31 08:54:14 2016
@@ -6,11 +6,10 @@
"""
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 +36,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 +80,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/twisted/names/test/test_names.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/names/test/test_names.py (original)
+++ branches/t-names-authority-py3-8259/twisted/names/test/test_names.py Thu Mar 31 08:54:14 2016
@@ -6,7 +6,10 @@
"""
import socket, operator, copy
-from StringIO import StringIO
+
+from io import BytesIO
+
+from twisted.python.compat import NativeStringIO
from functools import partial, reduce
from struct import pack
@@ -66,41 +69,41 @@
)
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_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, 'host.test-domain.com'),
- dns.Record_HINFO(os='Linux', cpu='A Fast One, Dontcha know'),
+ dns.Record_HINFO(os=b'Linux', cpu=b'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_TXT(b'A First piece of Text', b'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_TXT(b'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]!"),
+ 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('AF43:5634:1294:AFCB:56AC:48EF:34C3:01FF')],
- 'http.tcp.test-domain.com': [
+ b'http.tcp.test-domain.com': [
dns.Record_SRV(257, 16383, 43690, 'some.other.place.fool')
],
- 'host.test-domain.com': [
+ b'host.test-domain.com': [
dns.Record_A('123.242.1.5'),
dns.Record_A('0.255.0.255'),
],
- 'host-two.test-domain.com': [
+ b'host-two.test-domain.com': [
#
# Python bug
# dns.Record_A('255.255.255.255'),
@@ -108,18 +111,18 @@
dns.Record_A('255.255.255.254'),
dns.Record_A('0.0.0.0')
],
- 'cname.test-domain.com': [
+ b'cname.test-domain.com': [
dns.Record_CNAME('test-domain.com')
],
- 'anothertest-domain.com': [
+ b'anothertest-domain.com': [
dns.Record_A('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': [
+ b'123.93.84.28.in-addr.arpa': [
dns.Record_PTR('test.host-reverse.lookup.com'),
reverse_soa
]
@@ -128,9 +131,9 @@
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'),
@@ -251,9 +254,9 @@
"""
return self.namesTest(
self.resolver.lookupMailExchange(b"test-domain.com"),
- [dns.Record_MX(10, b"host.test-domain.com", ttl=19283784),
- dns.Record_A(b"123.242.1.5", ttl=19283784),
- dns.Record_A(b"0.255.0.255", ttl=19283784)])
+ [dns.Record_MX(10, "host.test-domain.com", ttl=19283784),
+ dns.Record_A("123.242.1.5", ttl=19283784),
+ dns.Record_A("0.255.0.255", ttl=19283784)])
def test_nameserver(self):
@@ -268,7 +271,7 @@
"""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 +348,8 @@
"""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 +359,8 @@
"""
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 +368,7 @@
"""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 +431,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 +513,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 +536,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)
@@ -613,8 +616,8 @@
Tests for L{FileAuthority}'s additional processing for those record types
which require it (MX, CNAME, etc).
"""
- _A = dns.Record_A(b"10.0.0.1")
- _AAAA = dns.Record_AAAA(b"f080::1")
+ _A = dns.Record_A("10.0.0.1")
+ _AAAA = dns.Record_AAAA("f080::1")
def _lookupSomeRecords(self, method, soa, makeRecord, target, addresses):
"""
@@ -969,7 +972,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 +984,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 +996,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(
@@ -1006,7 +1009,7 @@
retry=9600,
ttl=12000,
)
- a = Record_A(b'192.168.1.2', ttl=0)
+ a = Record_A('192.168.1.2', ttl=0)
answer = Message(id=query.id, answer=1, auth=1)
answer.answers.extend([
RRHeader(b'example.com', type=SOA, payload=soa),
Modified: branches/t-names-authority-py3-8259/twisted/python/dist3.py
==============================================================================
--- branches/t-names-authority-py3-8259/twisted/python/dist3.py (original)
+++ branches/t-names-authority-py3-8259/twisted/python/dist3.py Thu Mar 31 08:54:14 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",
@@ -317,6 +319,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",