Project

General

Profile

Bug #2471

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

Added by adwen over 6 years ago. Updated over 6 years ago.

Status:
Invalid
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-02-08
Due date:
% Done:

0%

Estimated time:
Missing in 1.5.x:
No

Description

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.

History

#1

Updated by darix over 6 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.

#2

Updated by adwen over 6 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?

#3

Updated by spaam over 6 years ago

your python file.

#4

Updated by adwen over 6 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....

#5

Updated by darix over 6 years ago

#6

Updated by adwen over 6 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!

#7

Updated by stbuehler over 6 years ago

  • Target version deleted (1.4.x)

Also available in: Atom