launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26018
[Merge] ~cjwatson/launchpad:py3-resource-render-bytes into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-resource-render-bytes into launchpad:master.
Commit message:
Return bytes from Resource.render* implementations
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396284
Twisted requires this on Python 3.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-resource-render-bytes into launchpad:master.
diff --git a/lib/lp/buildmaster/tests/snapbuildproxy.py b/lib/lp/buildmaster/tests/snapbuildproxy.py
index a1e2271..4341bda 100644
--- a/lib/lp/buildmaster/tests/snapbuildproxy.py
+++ b/lib/lp/buildmaster/tests/snapbuildproxy.py
@@ -55,7 +55,7 @@ class ProxyAuthAPITokensResource(resource.Resource):
"username": username,
"secret": uuid.uuid4().hex,
"timestamp": datetime.utcnow().isoformat(),
- })
+ }).encode("UTF-8")
class InProcessProxyAuthAPIFixture(fixtures.Fixture):
diff --git a/lib/lp/registry/tests/distributionmirror_http_server.py b/lib/lp/registry/tests/distributionmirror_http_server.py
index 37b889e..b814e3f 100644
--- a/lib/lp/registry/tests/distributionmirror_http_server.py
+++ b/lib/lp/registry/tests/distributionmirror_http_server.py
@@ -66,7 +66,7 @@ class DistributionMirrorTestHTTPServer(Resource):
return Resource.getChild(self, name, request)
def render_GET(self, request):
- return "Hi"
+ return b"Hi"
class DistributionMirrorTestSecureHTTPServer(DistributionMirrorTestHTTPServer):
@@ -82,7 +82,7 @@ class RedirectingResource(Resource):
def render_GET(self, request):
request.redirect(self.redirection_url)
- request.write('Get Lost')
+ request.write(b'Get Lost')
class NeverFinishResource(Resource):
@@ -93,4 +93,4 @@ class NeverFinishResource(Resource):
class FiveHundredResource(Resource):
def render_GET(self, request):
request.setResponseCode(500)
- request.write('ASPLODE!!!')
+ request.write(b'ASPLODE!!!')
diff --git a/lib/lp/services/signing/testing/fakesigning.py b/lib/lp/services/signing/testing/fakesigning.py
index 28877e9..91e2e59 100644
--- a/lib/lp/services/signing/testing/fakesigning.py
+++ b/lib/lp/services/signing/testing/fakesigning.py
@@ -38,7 +38,7 @@ class ServiceKeyResource(resource.Resource, object):
return json.dumps({
"service-key": self.service_public_key.encode(
encoder=Base64Encoder).decode("UTF-8"),
- })
+ }).encode("UTF-8")
class NonceResource(resource.Resource, object):
@@ -58,7 +58,7 @@ class NonceResource(resource.Resource, object):
nonce = base64.b64encode(random(Box.NONCE_SIZE)).decode("UTF-8")
self.nonces.append(nonce)
request.setHeader(b"Content-Type", b"application/json")
- return json.dumps({"nonce": nonce})
+ return json.dumps({"nonce": nonce}).encode("UTF-8")
class BoxedAuthenticationResource(resource.Resource, object):
diff --git a/lib/lp/services/twistedsupport/gracefulshutdown.py b/lib/lp/services/twistedsupport/gracefulshutdown.py
index bbd1b0c..a05903e 100644
--- a/lib/lp/services/twistedsupport/gracefulshutdown.py
+++ b/lib/lp/services/twistedsupport/gracefulshutdown.py
@@ -113,7 +113,7 @@ class ServerAvailableResource(resource.Resource):
request.setResponseCode(200)
else:
request.setResponseCode(503)
- request.setHeader('Content-Type', 'text/plain')
+ request.setHeader(b'Content-Type', b'text/plain')
return service_available
def render_GET(self, request):
@@ -127,15 +127,16 @@ class ServerAvailableResource(resource.Resource):
state_text = 'Available'
else:
state_text = 'Unavailable'
- return '%s\n\n%d connections: \n\n%s\n' % (
+ text = '%s\n\n%d connections: \n\n%s\n' % (
state_text, len(tracked_connections),
'\n'.join(
[str(c.transport.getPeer()) for c in tracked_connections]))
+ return text.encode('UTF-8')
def render_HEAD(self, request):
"""Handler for HEAD requests. See resource.Resource.render."""
self._render_common(request)
- return ''
+ return b''
@implementer(service.IServiceCollection)