← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-py3-basic-request-update-environ into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-py3-basic-request-update-environ into launchpad:master.

Commit message:
Fix AccessLoggingMiddleware to handle Unicode PATH_INFO

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Following ec3b4eb2004c26082f8893f7814f1cb43bd0501e, PATH_INFO is Unicode on Python 2.  Tweak AccessLoggingMiddleware to handle this.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-py3-basic-request-update-environ into launchpad:master.
diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
index ced93a0..1447f3b 100644
--- a/lib/lp/testing/layers.py
+++ b/lib/lp/testing/layers.py
@@ -75,6 +75,7 @@ from fixtures import (
     MonkeyPatch,
     )
 import psycopg2
+import six
 from six.moves.urllib.error import (
     HTTPError,
     URLError,
@@ -1629,7 +1630,8 @@ class AccessLoggingMiddleware:
         # here is gratuitously annoying.  This is similar to parts of
         # wsgiref.util.request_uri, but with slightly more lenient quoting.
         url = quote(
-            environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', ''),
+            six.ensure_str(
+                environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')),
             safe='/+')
         if environ.get('QUERY_STRING'):
             url += '?' + environ['QUERY_STRING']