Sudden error: SyntaxError: Non-ASCII character '\xc2' in file

eryksun () eryksun at gmail.com
Wed Mar 30 12:32:18 EDT 2011


On Wednesday, March 30, 2011 10:34:46 AM UTC-4, Gnarlodious wrote:
> 
> The error originates at '·' which string contains a ·
> character.
> 
> Complete error message is:
> 
> SyntaxError: Non-ASCII character '\xc2' in file /Library/WebServer/
> Sites/Sectrum/Site/Feed.py on line 17, but no encoding declared; see
> http://www.python.org/peps/pep-0263.html for details

A middle dot is Unicode \x00\xb7, which maps to UTF-8 \xc2\xb7. According to PEP 3120 the default source encoding for Python 3.x is UTF-8. (I'll take their word for it, since I'm still using 2.7). Are you declaring an ASCII encoding (e.g. # coding: ascii)? If not, are you sure that you're running in 3.x?



More information about the Python-list mailing list