The most strange is that before start the application the same formatting instruction works, it raises the error only inside the GET (or any other controller method).
The test program is:
==============================
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import web
class Index(object):
def GET(self, id = None):
if id:
# this raises UnicodeDecodeError
msg = 'Não encontrado: %s' % web.ctx.path
raise web.notfound(msg)
return 'Encontrei'
urls = (
'/(.*)', 'Index'
)
application = web.application(urls, globals())
# this works
msg = 'Não encontrado: %s' % '/test'
web.debug(msg)
if __name__=='__main__':
application.run()
==============================
beppler@squeeze:~/site$ python test.py
'N\xc3\xa3o encontrado: /test'
'N\xc3\xa3o encontrado: /test'
Traceback (most recent call last):
File "/home/beppler/Projects/elco/src/web/application.py", line 239, in process
return self.handle()
File "/home/beppler/Projects/elco/src/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)
File "/home/beppler/Projects/elco/src/web/application.py", line 462, in _delegate
return handle_class(cls)
File "/home/beppler/Projects/elco/src/web/application.py", line 438, in handle_class
return tocall(*args)
File "/home/beppler/Projects/elco/src/site/test.py", line 17, in GET
msg = 'Não encontrado: %s' % web.ctx.path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)