launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26513
[Merge] ~cjwatson/launchpad:py3-digest-search-resource into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-digest-search-resource into launchpad:master.
Commit message:
Fix DigestSearchResource for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398994
We need a few slight bytes/text adjustments: in particular, the "digest" argument is received as bytes, but we need to look it up in the database as text.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-digest-search-resource into launchpad:master.
diff --git a/lib/lp/services/librarian/doc/librarian.txt b/lib/lp/services/librarian/doc/librarian.txt
index 7c8b66c..598a8b5 100644
--- a/lib/lp/services/librarian/doc/librarian.txt
+++ b/lib/lp/services/librarian/doc/librarian.txt
@@ -459,13 +459,14 @@ So searching for the private content on the public librarian will fail:
>>> transaction.commit()
>>> search_query = "search?digest=%s" % restricted_file.content.sha1
- >>> print(urlopen(config.librarian.download_url + search_query).read())
+ >>> print(six.ensure_str(
+ ... urlopen(config.librarian.download_url + search_query).read()))
0
But on the restricted server, this will work:
- >>> result = urlopen(
- ... config.librarian.restricted_download_url + search_query).read()
+ >>> result = six.ensure_str(urlopen(
+ ... config.librarian.restricted_download_url + search_query).read())
>>> result = result.splitlines()
>>> print(result[0])
3
diff --git a/lib/lp/services/librarianserver/web.py b/lib/lp/services/librarianserver/web.py
index 25c373c..4bd8cce 100644
--- a/lib/lp/services/librarianserver/web.py
+++ b/lib/lp/services/librarianserver/web.py
@@ -316,8 +316,8 @@ class DigestSearchResource(resource.Resource):
def render_GET(self, request):
try:
- digest = request.args['digest'][0]
- except LookupError:
+ digest = six.ensure_text(request.args[b'digest'][0])
+ except (LookupError, UnicodeDecodeError):
return static.Data(
b'Bad search', six.ensure_str('text/plain')).render(request)