StaticFileHandler errors with non-ascii path #716

wmslei opened this Issue Apr 7, 2013 · 2 comments

2 participants


Uncaught exception GET /static/chat.js?v=8dadd (
HTTPRequest(protocol='http', host='', method='GET', uri='/static/chat.js?v=8dadd', version='HTTP/1.1', remote_ip='', body='', headers={'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Host': '', 'Accept': '/', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/20100101 Firefox/19.0', 'Connection': 'keep-alive', 'Referer': '', 'Cookie': 'chatdemo_user="eyJjbGFpbWVkX2lkIjogImh0dHBzOi8vd3d3Lmdvb2dsZS5jb20vYWNjb3VudHMvbzgvaWQ/aWQ9QUl0T2F3bGptbHZHTmtuTkRkckw0cC1ub2xzSzVNSjBYZ2FlcEc0IiwgImZpcnN0X25hbWUiOiAiXHU3OGNhIiwgImxhc3RfbmFtZSI6ICJcdTViNTkiLCAibmFtZSI6ICJcdTc4Y2EgXHU1YjU5In0=|1365320273|c93e31f9e6d462c8c95ed14e534a7d8fc3cf312c"; _xsrf=edeb3a8aa7b646dd980191b93f15e830'})
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado-3.0-py2.7.egg/tornado/", line 1077, in _execute
self.path_args, *self.path_kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado-3.0-py2.7.egg/tornado/", line 1622, in get
abspath = os.path.abspath(os.path.join(self.root, path))
File "/usr/lib/python2.7/", line 78, in join
path += b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 15: ordinal not in range(128)
[E 130407 17:04:37 web:1514] 500 GET /static/chat.js?v=8dadd ( 0.84ms

@bdarnell bdarnell referenced this issue Apr 7, 2013

chat demo 500 #714

tornadoweb member

OK, now we're getting somewhere. It looks like you have non-ascii characters in a directory name somewhere, and this causes an error when character strings and byte strings are mixed in python 2. I'm not sure where exactly you're getting a character string here; as far as I can tell all the path functions used in this demo use byte strings on python 2.

If you'd like to investigate further and figure out where the character string is coming from we can add a fix, but I expect this problem will be common in other libraries too. I recommend working from a directory whose path contains only ascii characters, or moving to python 3 where non-ascii characters do not generally cause problems.

@bdarnell bdarnell referenced this issue Apr 7, 2013

chat demo 500 #715


import sys

I insert these code in ../demos/chat/,then the demo can working.

@wmslei wmslei closed this Apr 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment