← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-oops-url-text into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-oops-url-text into launchpad:master.

Commit message:
Make 'url' field in OOPS reports be text, not bytes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398818
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-oops-url-text into launchpad:master.
diff --git a/lib/lp/codehosting/puller/tests/test_scheduler.py b/lib/lp/codehosting/puller/tests/test_scheduler.py
index 10b0f55..6aabd08 100644
--- a/lib/lp/codehosting/puller/tests/test_scheduler.py
+++ b/lib/lp/codehosting/puller/tests/test_scheduler.py
@@ -449,7 +449,7 @@ class TestPullerMaster(TestCase):
         self.assertEqual('error message', oops['value'])
         self.assertEqual('RuntimeError', oops['type'])
         self.assertEqual(
-            six.ensure_binary(get_canonical_url_for_branch_name(
+            six.ensure_text(get_canonical_url_for_branch_name(
                 self.eventHandler.unique_name)), oops['url'])
 
     def test_startMirroring(self):
diff --git a/lib/lp/services/webapp/errorlog.py b/lib/lp/services/webapp/errorlog.py
index 4c3ed01..0ec77cb 100644
--- a/lib/lp/services/webapp/errorlog.py
+++ b/lib/lp/services/webapp/errorlog.py
@@ -160,13 +160,12 @@ def attach_http_request(report, context):
     #      undo. URL is just too HTTPRequest-specific.
     if safe_hasattr(request, 'URL'):
         # URL's are byte strings, but possibly str() will fail - safe_unicode
-        # handles all those cases, and then we can safely encode it to utf8.
-        # This is strictly double handling as a URL should never have unicode
-        # characters in it anyway (though it may have them % encoded, which is
-        # fine). Better safe than sorry, and the safe_unicode handling won't
-        # cause double-encoding, so it is safe.
-        url = oops.createhooks.safe_unicode(request.URL).encode('utf8')
-        report['url'] = url
+        # handles all those cases.  This is strictly double handling as a
+        # URL should never have unicode characters in it anyway (though it
+        # may have them % encoded, which is fine).  Better safe than sorry,
+        # and the safe_unicode handling won't cause double-encoding, so it
+        # is safe.
+        report['url'] = oops.createhooks.safe_unicode(request.URL)
 
     if WebServiceLayer.providedBy(request) and info is not None:
         webservice_error = getattr(