Bug #2471


mod_cgi + python 3.2.3 = issue with utf-8 special characters (ñ, é, ç).

Added by adwen about 11 years ago. Updated over 10 years ago.

Target version:


lighttpd is quite a handful. It took me forever to realise that the problem was not my code (or python) but lighttpd :(. It is really unworkable guys. The simplest thing like moving lighttpd from port 80 to some other port gave was not doable. I want to adopt this new web server but it is not easy to work with. (tried using it with mono and it give me hell every single step of the way) Now with python this bug I've seen enough.

This issue is easy to reproduce. I have 2 python versions on my linux pc 2.7 en 3.2. The default version on my linux pc 2.7 (/usr/bin/python) and the alternative version at '/usr/bin/python3' For the code I'm using the python 3.2.3 so ofcourse I add in my conf file the following line: 'cgi.assign = ( ".py" => "/usr/bin/python3" )'. So I run the script via lighttpd (1.4.31) and I get the following error: 'UnicodeEncodeError: 'ascii' codec can't encode character '\xf1' in position 36: ordinal not in range(128)'

I run the same script directly on python and I have no errors. I hope this helps you make lighttpd better product.

Actions #1

Updated by darix about 11 years ago

  • Status changed from New to Invalid

that error message is from your python interpreter!
not from lighty

put a

# encoding: UTF-8

comment in your file. it might work for your shell because that is set to UTF-8. the locale in which lighty is started is mostlikely "C". so it doesnt know how to interpret that byte.

Actions #2

Updated by adwen about 11 years ago

Thnx darix for the speedy response

You want me to put '# encoding: UTF-8' in my file. What file are you referring to? my python file? my conf file?

Actions #3

Updated by spaam about 11 years ago

your python file.

Actions #4

Updated by adwen about 11 years ago

Ok. I cannot get it to work. Pardon my ignorance on the matter but it seems like something very normal (that I need to set this line in my code). But I've added the '# encoding: UTF-8' line at the top, in the middle, at the bottom of my file. It doesn't change my result. Is it some sort of preprocessor directive? Is there any documentation about this line? sigh....

Actions #5

Updated by darix about 11 years ago

Actions #6

Updated by adwen about 11 years ago

Thnx darix! I've read the documentation (written in 2001) but I couldn't find it anywhere stating that is still relevant in python 3.X onwards. I did give it a try but with no luck again. So I will leave it that. but thnx for the help! I appreciate it!

Actions #7

Updated by stbuehler over 10 years ago

  • Target version deleted (1.4.x)

Also available in: Atom