holden431 / browsershots

Automatically exported from code.google.com/p/browsershots
0 stars 0 forks source link

Default encoding in python files #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
My locale is ru_RU.UTF8, therefore variable __date__ contains unicode 
symbols: "$Date: 2007-12-29 19:51:29 +0300 (Сбт, 29 Дек 2007) $"
It causes errors like following: SyntaxError: Non-ASCII character '\xd0' in 
file /home/lomereiter/shotfactory/shotfactory04/image/__init__.py on line 
22, but no encoding declared; see http://www.python.org/peps/pep-0263.html 
for details

To fix that, I had to manually add # -*- coding: utf-8 -*- line in all files 
containing __date__ variable. 

Original issue reported on code.google.com by lomereiter on 28 Mar 2010 at 8:41

GoogleCodeExporter commented 8 years ago
I had the same problem (fr_FR locale), and it's quite annoying. Here's a Linux 
command that will had the coding header to each python file.

sed -i "2i # -*- coding: utf-8 -*-" `find -name "*.py"` 

Original comment by tailsze...@gmail.com on 29 Jun 2010 at 10:13