Merge ~cjwatson/launchpad:py3-pageid-str into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: fa1c71162bb9b928bf4ab7b4b2ec54d6b0111182
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-pageid-str
Merge into: launchpad:master
Diff against target: 19 lines (+4/-4)
1 file modified
lib/lp/services/webapp/publication.py (+4/-4)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+392386@code.launchpad.net

Commit message

Make constructPageID return a native string

Description of the change

On Python 3, we want str rather than bytes.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
2index 6324a64..86a8b65 100644
3--- a/lib/lp/services/webapp/publication.py
4+++ b/lib/lp/services/webapp/publication.py
5@@ -410,10 +410,10 @@ class LaunchpadBrowserPublication(
6 return self.constructPageID(context, context.context, names)
7 view_names = ':'.join(names)
8 pageid = '%s:%s' % (context_name, view_names)
9- # The view name used in the pageid usually comes from ZCML and so
10- # it will be a unicode string although it shouldn't. To avoid
11- # problems we encode it into ASCII.
12- return pageid.encode('US-ASCII')
13+ # The view name used in the pageid usually comes from ZCML and so it
14+ # will be a Unicode string, but we want a native string. On Python
15+ # 2, to avoid problems we encode it into ASCII.
16+ return six.ensure_str(pageid, 'US-ASCII')
17
18 def callObject(self, request, ob):
19 """See `zope.publisher.interfaces.IPublication`.

Subscribers

People subscribed via source and target branches

to status/vote changes: