← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-twisted-web-child-names into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-twisted-web-child-names into launchpad:master.

Commit message:
twisted.web.resource child names are bytes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/386714

Twisted 19.7.0 deprecated passing path to Resource.putChild as non-bytes.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-twisted-web-child-names into launchpad:master.
diff --git a/daemons/librarian.tac b/daemons/librarian.tac
index bc55c5c..4440621 100644
--- a/daemons/librarian.tac
+++ b/daemons/librarian.tac
@@ -91,8 +91,8 @@ def setUpListener(uploadPort, webPort, restricted):
         librarianService)
     root = fatweb.LibraryFileResource(
         librarian_storage, upstreamHost, upstreamPort)
-    root.putChild('search', fatweb.DigestSearchResource(librarian_storage))
-    root.putChild('robots.txt', fatweb.robotsTxt)
+    root.putChild(b'search', fatweb.DigestSearchResource(librarian_storage))
+    root.putChild(b'robots.txt', fatweb.robotsTxt)
     site = server.Site(root)
     site.displayTracebacks = False
     strports.service("tcp:%d" % webPort, site).setServiceParent(
diff --git a/lib/lp/buildmaster/tests/snapbuildproxy.py b/lib/lp/buildmaster/tests/snapbuildproxy.py
index 21d973e..fc8893a 100644
--- a/lib/lp/buildmaster/tests/snapbuildproxy.py
+++ b/lib/lp/buildmaster/tests/snapbuildproxy.py
@@ -81,7 +81,7 @@ class InProcessProxyAuthAPIFixture(fixtures.Fixture):
     def start(self):
         root = resource.Resource()
         self.tokens = ProxyAuthAPITokensResource()
-        root.putChild("tokens", self.tokens)
+        root.putChild(b"tokens", self.tokens)
         endpoint = endpoints.serverFromString(reactor, nativeString("tcp:0"))
         site = server.Site(self.tokens)
         self.addCleanup(site.stopFactory)
diff --git a/lib/lp/registry/tests/distributionmirror_http_server.py b/lib/lp/registry/tests/distributionmirror_http_server.py
index a23149c..37b889e 100644
--- a/lib/lp/registry/tests/distributionmirror_http_server.py
+++ b/lib/lp/registry/tests/distributionmirror_http_server.py
@@ -37,15 +37,15 @@ class DistributionMirrorTestHTTPServer(Resource):
     def getChild(self, name, request):
         protocol = self.protocol
         port = request.getHost().port
-        if name == 'valid-mirror':
+        if name == b'valid-mirror':
             leaf = self.__class__()
             leaf.isLeaf = True
             return leaf
-        elif name == 'timeout':
+        elif name == b'timeout':
             return NeverFinishResource()
-        elif name == 'error':
+        elif name == b'error':
             return FiveHundredResource()
-        elif name == 'redirect-to-valid-mirror':
+        elif name == b'redirect-to-valid-mirror':
             assert request.path != name, (
                 'When redirecting to a valid mirror the path must have more '
                 'than one component.')
@@ -55,11 +55,11 @@ class DistributionMirrorTestHTTPServer(Resource):
                     protocol, port, remaining_path))
             leaf.isLeaf = True
             return leaf
-        elif name == 'redirect-infinite-loop':
+        elif name == b'redirect-infinite-loop':
             return RedirectingResource(
                 '%s://localhost:%s/redirect-infinite-loop' %
                 (protocol, port))
-        elif name == 'redirect-unknown-url-scheme':
+        elif name == b'redirect-unknown-url-scheme':
             return RedirectingResource(
                 'ssh://localhost/redirect-unknown-url-scheme')
         else:
diff --git a/lib/lp/services/librarianserver/web.py b/lib/lp/services/librarianserver/web.py
index 90001dc..40013dd 100644
--- a/lib/lp/services/librarianserver/web.py
+++ b/lib/lp/services/librarianserver/web.py
@@ -68,7 +68,7 @@ class LibraryFileResource(resource.Resource):
         self.upstreamPort = upstreamPort
 
     def getChild(self, name, request):
-        if name == '':
+        if name == b'':
             # Root resource
             return defaultResource
         try:
diff --git a/lib/lp/services/twistedsupport/gracefulshutdown.py b/lib/lp/services/twistedsupport/gracefulshutdown.py
index bd21da5..bbd1b0c 100644
--- a/lib/lp/services/twistedsupport/gracefulshutdown.py
+++ b/lib/lp/services/twistedsupport/gracefulshutdown.py
@@ -169,6 +169,6 @@ def make_web_status_service(strport, tracking_factories):
     """
     server_available_resource = ServerAvailableResource(tracking_factories)
     web_root = resource.Resource()
-    web_root.putChild('', server_available_resource)
+    web_root.putChild(b'', server_available_resource)
     web_factory = server.Site(web_root)
     return strports.service(strport, web_factory)
diff --git a/lib/lp/testing/keyserver/web.py b/lib/lp/testing/keyserver/web.py
index 0ad0926..faac2e8 100644
--- a/lib/lp/testing/keyserver/web.py
+++ b/lib/lp/testing/keyserver/web.py
@@ -82,7 +82,7 @@ class _BaseResource(Resource):
 
     def getChild(self, name, request):
         """Redirect trailing slash correctly."""
-        if name == '':
+        if name == b'':
             return self
         return Resource.getChild(
             self, name, request)
@@ -93,7 +93,7 @@ class KeyServerResource(_BaseResource):
 
     def __init__(self, root):
         _BaseResource.__init__(self)
-        self.putChild('pks', PksResource(root))
+        self.putChild(b'pks', PksResource(root))
 
     def render_GET(self, request):
         return GREETING
@@ -103,8 +103,8 @@ class PksResource(_BaseResource):
 
     def __init__(self, root):
         _BaseResource.__init__(self)
-        self.putChild('lookup', LookUp(root))
-        self.putChild('add', SubmitKey(root))
+        self.putChild(b'lookup', LookUp(root))
+        self.putChild(b'add', SubmitKey(root))
 
     def render_GET(self, request):
         return 'Welcome To Fake SKS service.\n'
diff --git a/lib/lp/testing/swift/fakeswift.py b/lib/lp/testing/swift/fakeswift.py
index e9eb5b7..eedaa77 100644
--- a/lib/lp/testing/swift/fakeswift.py
+++ b/lib/lp/testing/swift/fakeswift.py
@@ -102,7 +102,7 @@ class FakeKeystone(resource.Resource):
 
     def getChild(self, path, request):
         """See `twisted.web.resource.Resource.getChild`."""
-        if path in ("v2.0", "tokens"):
+        if path in (b"v2.0", b"tokens"):
             return self
         return resource.NoResource("Not a valid keystone URL.")
 
@@ -522,7 +522,7 @@ class FakeSwift(resource.Resource):
 
     def getChild(self, name, request):
         """See `twisted.web.resource.Resource.getChild`."""
-        if name == "v1" or name.startswith("AUTH_"):
+        if name == b"v1" or name.startswith(b"AUTH_"):
             return self
 
         resource = self._getResource(name, request)
@@ -556,8 +556,8 @@ class Root(resource.Resource):
         self.keystone = FakeKeystone(
             self, allow_default_access=allow_default_access)
         self.swift = FakeSwift(self)
-        self.putChild("keystone", self.keystone)
-        self.putChild("swift", self.swift)
+        self.putChild(b"keystone", self.keystone)
+        self.putChild(b"swift", self.swift)
 
     def getCatalog(self, tenant, request):
         """Compute service catalog for the given request and tenant."""