← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-NotFound-native-string into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-NotFound-native-string into launchpad:master.

Commit message:
Raise NotFound errors with name as a native string in most cases

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This makes doctest compatibility between Python 2 and 3 easier.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-NotFound-native-string into launchpad:master.
diff --git a/lib/lp/registry/stories/distribution/xx-distribution-overview.txt b/lib/lp/registry/stories/distribution/xx-distribution-overview.txt
index 8fb8a3a..8deff14 100644
--- a/lib/lp/registry/stories/distribution/xx-distribution-overview.txt
+++ b/lib/lp/registry/stories/distribution/xx-distribution-overview.txt
@@ -127,7 +127,7 @@ If there is a development series alias, it becomes a redirect.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: u'devel'
+    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: 'devel'
 
     >>> with celebrity_logged_in("admin"):
     ...     ubuntu = getUtility(IDistributionSet).getByName(u"ubuntu")
@@ -180,10 +180,10 @@ results in a NotFound error.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: u'+archive'
+    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: '+archive'
 
     >>> anon_browser.open("http://launchpad.test/ubuntu/+archive/boing";)
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: u'boing'
+    zope.publisher.interfaces.NotFound: Object: <Distribution ...>, name: 'boing'
diff --git a/lib/lp/registry/stories/mailinglists/lifecycle.txt b/lib/lp/registry/stories/mailinglists/lifecycle.txt
index 56b4c65..203f3c2 100644
--- a/lib/lp/registry/stories/mailinglists/lifecycle.txt
+++ b/lib/lp/registry/stories/mailinglists/lifecycle.txt
@@ -233,7 +233,7 @@ private team.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <...>, name: u'~bassists'
+    zope.publisher.interfaces.NotFound: Object: <...>, name: '~bassists'
 
 The same is true for normal users who are not team members.
 
@@ -241,7 +241,7 @@ The same is true for normal users who are not team members.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <...>, name: u'~bassists'
+    zope.publisher.interfaces.NotFound: Object: <...>, name: '~bassists'
 
 Members who are not owners can see the link.
 
@@ -251,7 +251,7 @@ Members who are not owners can see the link.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <...>, name: u'~bassists'
+    zope.publisher.interfaces.NotFound: Object: <...>, name: '~bassists'
 
     >>> admin_browser.open('http://launchpad.test/~bassists/+addmember')
     >>> admin_browser.getControl('New member').value = 'cprov'
diff --git a/lib/lp/services/webapp/doc/renamed-view.txt b/lib/lp/services/webapp/doc/renamed-view.txt
index 2a8fd70..5d12bec 100644
--- a/lib/lp/services/webapp/doc/renamed-view.txt
+++ b/lib/lp/services/webapp/doc/renamed-view.txt
@@ -90,7 +90,7 @@ raise an error. e.g. http://launchpad.test/ubuntu/+tickets/foo
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
      ...
-    zope.publisher.interfaces.NotFound: Object: <Distribution 'Ubuntu' (ubuntu)>, name: u'foo'
+    zope.publisher.interfaces.NotFound: Object: <Distribution 'Ubuntu' (ubuntu)>, name: 'foo'
 
 
 == Registering from ZCML ==
diff --git a/lib/lp/services/webapp/publisher.py b/lib/lp/services/webapp/publisher.py
index e0eb82e..6b76a7e 100644
--- a/lib/lp/services/webapp/publisher.py
+++ b/lib/lp/services/webapp/publisher.py
@@ -504,7 +504,8 @@ class LaunchpadView(UserAttributeCache):
         """See IBrowserPublisher."""
         # By default, a LaunchpadView cannot be traversed through.
         # Those that can be must override this method.
-        raise NotFound(self, name, request=request)
+        raise NotFound(
+            self, six.ensure_str(name, errors='replace'), request=request)
 
     @property
     def recommended_canonical_url(self):
@@ -968,7 +969,8 @@ class Navigation:
         """
         # Avoid circular imports.
         if nextobj is None:
-            raise NotFound(self.context, name)
+            raise NotFound(
+                self.context, six.ensure_str(name, errors='replace'))
         elif isinstance(nextobj, redirection):
             return RedirectionView(
                 nextobj.name, request, status=nextobj.status)
@@ -1188,7 +1190,7 @@ class RenamedView:
 
     def publishTraverse(self, request, name):
         """See zope.publisher.interfaces.browser.IBrowserPublisher."""
-        raise NotFound(self.context, name)
+        raise NotFound(self.context, six.ensure_str(name, errors='replace'))
 
     def browserDefault(self, request):
         """See zope.publisher.interfaces.browser.IBrowserPublisher."""
diff --git a/lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt b/lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt
index cd2e81b..87c1963 100644
--- a/lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt
+++ b/lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt
@@ -680,10 +680,10 @@ result in a NotFound error.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <Person at ... name16 (Foo Bar)>, name: u'+archive'
+    zope.publisher.interfaces.NotFound: Object: <Person at ... name16 (Foo Bar)>, name: '+archive'
 
     >>> admin_browser.open("http://launchpad.test/~name16/+archive";)
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: <Person at ... name16 (Foo Bar)>, name: u'+archive'
+    zope.publisher.interfaces.NotFound: Object: <Person at ... name16 (Foo Bar)>, name: '+archive'
diff --git a/lib/lp/translations/stories/standalone/xx-pofile-translate.txt b/lib/lp/translations/stories/standalone/xx-pofile-translate.txt
index a7876ee..2d8e3a9 100644
--- a/lib/lp/translations/stories/standalone/xx-pofile-translate.txt
+++ b/lib/lp/translations/stories/standalone/xx-pofile-translate.txt
@@ -118,7 +118,7 @@ in the past.
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
     ...
-    zope.publisher.interfaces.NotFound: Object: ... name: u'en'
+    zope.publisher.interfaces.NotFound: Object: ... name: 'en'
 
 See xx-pofile-translate-alternative-language.txt for details about
 the 'make suggestions from' feature.