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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 4f95a035f728c1212429b957fbb58857a451818f
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-py3-basic-request-update-environ
Merge into: launchpad:master
Diff against target: 22 lines (+3/-1)
1 file modified
lib/lp/testing/layers.py (+3/-1)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+398149@code.launchpad.net

Commit message

Fix AccessLoggingMiddleware to handle Unicode PATH_INFO

Description of the change

Following ec3b4eb2004c26082f8893f7814f1cb43bd0501e, PATH_INFO is Unicode on Python 2. Tweak AccessLoggingMiddleware to handle this.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
2index ced93a0..1447f3b 100644
3--- a/lib/lp/testing/layers.py
4+++ b/lib/lp/testing/layers.py
5@@ -75,6 +75,7 @@ from fixtures import (
6 MonkeyPatch,
7 )
8 import psycopg2
9+import six
10 from six.moves.urllib.error import (
11 HTTPError,
12 URLError,
13@@ -1629,7 +1630,8 @@ class AccessLoggingMiddleware:
14 # here is gratuitously annoying. This is similar to parts of
15 # wsgiref.util.request_uri, but with slightly more lenient quoting.
16 url = quote(
17- environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', ''),
18+ six.ensure_str(
19+ environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', '')),
20 safe='/+')
21 if environ.get('QUERY_STRING'):
22 url += '?' + environ['QUERY_STRING']

Subscribers

People subscribed via source and target branches

to status/vote changes: