New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if chinese directory path,SimpleTemplate Faied. #552

D-L opened this Issue Sep 29, 2013 · 0 comments


None yet
1 participant

D-L commented Sep 29, 2013

directory path contain any chinese word,when launch the bottle server.
it's crushed. Error: 500 Internal Server Error

this directory views:

  ├──    latest version
  └── views
     ├── foot.tpl
     └── home.tpl

== ==

#!/usr/bin/env python2
#coding: utf8
from bottle import get,run,template
def test():
    return template("home")
if __name__=="__main__":

== home.tpl ==

<!doctype html>
        <meta charset="utf-8">
        <title>test Chinese dir path</title>
        test chinese path!
        %include foot

== foot.tpl ==

<p>we @ foot</p>

== error msg ==

Traceback (most recent call last):
  File "/home/david/test/中文/", line 861, in _handle
  File "/home/david/test/中文/", line 1725, in wrapper
    rv = callback(*a, **ka)
  File "./", line 7, in test
    return template("home")
  File "/home/david/test/中文/", line 3465, in template
    return TEMPLATES[tplid].render(kwargs)
  File "/home/david/test/中文/", line 3273, in render
    self.execute(stdout, env)
  File "/home/david/test/中文/", line 3260, in execute
    eval(, env)
  File "/home/david/test/中文/views/home.tpl", line 9, in <module>
    %include foot
  File "/home/david/test/中文/", line 3249, in _include
    self.cache[_name] = self.__class__(name=_name, lookup=self.lookup)
  File "/home/david/test/中文/", line 3088, in __init__
    self.filename =, self.lookup)
  File "/home/david/test/中文/", line 3109, in search
    fname = os.path.abspath(os.path.join(spath, name))
  File "/home/david/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/", line 69, in join
    path +=  b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 17: ordinal not in range(128)

=== solution? ===
i change the line 3088

  self.filename =, self.lookup)


  self.filename =,encoding), self.lookup)

Looks fixed.

test case @:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment