diff options
| -rw-r--r-- | pyramid/tests/test_traversal.py | 6 | ||||
| -rw-r--r-- | pyramid/traversal.py | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/pyramid/tests/test_traversal.py b/pyramid/tests/test_traversal.py index 9af47aec3..cf1f841ec 100644 --- a/pyramid/tests/test_traversal.py +++ b/pyramid/tests/test_traversal.py @@ -284,8 +284,7 @@ class ResourceTreeTraverserTests(unittest.TestCase): segment = native_(text_(b'LaPe\xc3\xb1a', 'utf-8'), 'utf-16') environ = self._getEnviron(PATH_INFO='/%s' % segment) request = DummyRequest(environ) - from pyramid.exceptions import URLDecodeError - self.assertRaises(URLDecodeError, policy, request) + self.assertRaises(UnicodeEncodeError, policy, request) def test_non_utf8_path_segment_settings_unicode_path_segments_fails(self): foo = DummyContext() @@ -294,8 +293,7 @@ class ResourceTreeTraverserTests(unittest.TestCase): segment = native_(text_(b'LaPe\xc3\xb1a', 'utf-8'), 'utf-16') environ = self._getEnviron(PATH_INFO='/%s' % segment) request = DummyRequest(environ) - from pyramid.exceptions import URLDecodeError - self.assertRaises(URLDecodeError, policy, request) + self.assertRaises(UnicodeEncodeError, policy, request) def test_withroute_nothingfancy(self): resource = DummyContext() diff --git a/pyramid/traversal.py b/pyramid/traversal.py index 366bee563..4d6a18b0d 100644 --- a/pyramid/traversal.py +++ b/pyramid/traversal.py @@ -478,9 +478,8 @@ def traversal_path(path): their own traversal machinery, as opposed to users writing applications in :app:`Pyramid`. """ - if (not PY3) and (isinstance(path, text_type)): - # XXX this stinks - path = path.encode('ascii') + if isinstance(path, text_type): + path.encode('ascii') # check for asci-only-ness path = path.strip('/') clean = [] for segment in path.split('/'): |
