summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-09-25 03:37:30 -0400
committerChris McDonough <chrism@plope.com>2011-09-25 03:37:30 -0400
commitc779f17dd60745e033075df2d76ab168cc2ecfd5 (patch)
tree859b8f038ae2115d9b73f5cd6f5300b1be2d7671
parentf4bdf9e8a7e9598042c53d96f1539b431880ec3f (diff)
downloadpyramid-c779f17dd60745e033075df2d76ab168cc2ecfd5.tar.gz
pyramid-c779f17dd60745e033075df2d76ab168cc2ecfd5.tar.bz2
pyramid-c779f17dd60745e033075df2d76ab168cc2ecfd5.zip
all tests pass on 3.2
-rw-r--r--pyramid/request.py7
-rw-r--r--pyramid/tests/test_request.py13
2 files changed, 13 insertions, 7 deletions
diff --git a/pyramid/request.py b/pyramid/request.py
index 6b77b09e9..afeee4bb2 100644
--- a/pyramid/request.py
+++ b/pyramid/request.py
@@ -13,6 +13,8 @@ from pyramid.interfaces import IResponseFactory
from pyramid.compat import json
from pyramid.compat import iterkeys_, itervalues_, iteritems_
from pyramid.compat import text_
+from pyramid.compat import bytes_
+from pyramid.compat import native_
from pyramid.exceptions import ConfigurationError
from pyramid.decorator import reify
from pyramid.response import Response
@@ -406,7 +408,8 @@ def call_app_with_subpath_as_path_info(request, app):
new_script_name = ''
# compute new_path_info
- new_path_info = '/' + '/'.join([x.encode('utf-8') for x in subpath])
+ new_path_info = '/' + '/'.join([native_(x.encode('utf-8'), 'latin-1')
+ for x in subpath])
if new_path_info != '/': # don't want a sole double-slash
if path_info != '/': # if orig path_info is '/', we're already done
@@ -424,7 +427,7 @@ def call_app_with_subpath_as_path_info(request, app):
break
el = workback.pop()
if el:
- tmp.insert(0, el.decode('utf-8'))
+ tmp.insert(0, text_(bytes_(el, 'latin-1'), 'utf-8'))
# strip all trailing slashes from workback to avoid appending undue slashes
# to end of script_name
diff --git a/pyramid/tests/test_request.py b/pyramid/tests/test_request.py
index c731edb7f..9d48d3b6e 100644
--- a/pyramid/tests/test_request.py
+++ b/pyramid/tests/test_request.py
@@ -3,6 +3,7 @@ from pyramid import testing
from pyramid.compat import text_
from pyramid.compat import bytes_
+from pyramid.compat import native_
from pyramid.compat import iteritems_, iterkeys_, itervalues_
class TestRequest(unittest.TestCase):
@@ -501,14 +502,16 @@ class Test_call_app_with_subpath_as_path_info(unittest.TestCase):
self.assertEqual(request.environ['PATH_INFO'], '/hello/')
def test_subpath_path_info_and_script_name_have_utf8(self):
- la = 'La Pe\xc3\xb1a'
- request = DummyRequest({'PATH_INFO':'/'+la, 'SCRIPT_NAME':'/'+la})
- request.subpath = (text_(la, 'utf-8'), )
+ encoded = native_(text_(b'La Pe\xc3\xb1a'))
+ decoded = text_(bytes_(encoded), 'utf-8')
+ request = DummyRequest({'PATH_INFO':'/' + encoded,
+ 'SCRIPT_NAME':'/' + encoded})
+ request.subpath = (decoded, )
response = self._callFUT(request, 'app')
self.assertTrue(request.copied)
self.assertEqual(response, 'app')
- self.assertEqual(request.environ['SCRIPT_NAME'], '/' + la)
- self.assertEqual(request.environ['PATH_INFO'], '/' + la)
+ self.assertEqual(request.environ['SCRIPT_NAME'], '/' + encoded)
+ self.assertEqual(request.environ['PATH_INFO'], '/' + encoded)
class DummyRequest:
def __init__(self, environ=None):