launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26514
[Merge] ~cjwatson/launchpad:py3-breadcrumb-repr into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-breadcrumb-repr into launchpad:master.
Commit message:
Fix Breadcrumb.__repr__ for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398998
Trying to substitute bytes into the return value results in something strange like `text='b'Breadcrumb text''`, which isn't what we want.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-breadcrumb-repr into launchpad:master.
diff --git a/lib/lp/services/webapp/breadcrumb.py b/lib/lp/services/webapp/breadcrumb.py
index 57e73b1..e9a9e6c 100644
--- a/lib/lp/services/webapp/breadcrumb.py
+++ b/lib/lp/services/webapp/breadcrumb.py
@@ -12,7 +12,7 @@ __all__ = [
'TitleBreadcrumb',
]
-
+import six
from zope.interface import implementer
from lp.services.webapp import canonical_url
@@ -82,7 +82,7 @@ class Breadcrumb:
# XXX: salgado, 2009-10-14, http://bugs.python.org/issue5876: In
# python 2.5-2.7, the return value of __repr__() may be forced into a
# type(str), so we can't include unicode here.
- text = self.text.encode('raw-unicode-escape')
+ text = six.ensure_str(self.text, 'raw-unicode-escape')
return "<%s url='%s' text='%s'>" % (
self.__class__.__name__, self.url, text)