Pylons/pyramid — Issue #385: UnicodeEncodeError when encoded URL and traversal. Dispatch OK.
Author: mrdobrzanski
Created: 2011-12-28 14:33:30+00:00
State: open

When request URL is ascii both dispatch and traversal work but when URL is encoded dispatch works but traversal returns error UnicodeEncodeError: 'latin-1' codec can't encode character u'\u0105' in position 1: ordinal not in range(256). for url: http://localhost:6543/traversal/a%C5%9B

Here's code I've used.

```python
from pyramid.config import Configurator
from pyramid.response import Response
from paste.httpserver import serve

class Root(object):
def __init__(self, request):
pass

def __getitem__(self, key):
return Resource(key)

class Resource(dict):
def __init__(self, v):
self.val = v

#view
def the_view(context, request):
return Response(request.path_info)

#server
if __name__ == '__main__':
config = Configurator()
config.add_route('the_route', 'dispatch/{foo}', request_method='GET')
config.add_view(the_view, route_name='the_route')

config.add_route('trav_route', 'traversal/{traverse:.*}', factory=Root, request_method='GET')
config.add_view(the_view, route_name='trav_route')

serve(config.make_wsgi_app(), port='6543')
```