Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2234

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <bsk16@case.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'wed,': 0.04; 'python': 0.07; 'dev': 0.09; 'encoding.': 0.09; 'specified,': 0.09; 'url:peps': 0.09; 'subject:error': 0.12; 'am,': 0.14; 'received:74.125.82.44': 0.14; 'received:mail-ww0-f44.google.com': 0.14; 'wrote:': 0.14; '3),': 0.16; '3.1.1': 0.16; 'ascii,': 0.16; 'declared;': 0.16; 'osx)': 0.16; 'sequence.': 0.16; 'url:pep-0263': 0.16; 'converting': 0.16; 'subject:file': 0.16; 'fine': 0.18; "subject:' ": 0.19; 'code': 0.22; 'header:In-Reply- To:1': 0.22; 'fix': 0.24; 'runs': 0.24; 'byte': 0.25; 'script': 0.26; 'ago': 0.26; 'url:mailman': 0.27; 'message- id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'string': 0.29; 'error': 0.29; 'server': 0.29; 'unicode': 0.29; '(the': 0.30; '17,': 0.31; 'character.': 0.31; 'rss': 0.31; 'does': 0.31; 'to:addr:python-list': 0.32; 'url:listinfo': 0.33; 'character': 0.33; 'updated': 0.33; 'skip:" 10': 0.34; 'starting': 0.34; 'file.': 0.34; 'file': 0.35; 'put': 0.35; 'running': 0.36; 'rather': 0.36; 'error.': 0.36; 'problem.': 0.36; 'some': 0.37; 'machine': 0.37; 'should': 0.37; 'url:python': 0.37; 'run': 0.37; 'sequence': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'url:org': 0.38; 'anything': 0.38; 'help': 0.39; 'errors': 0.39; 'common': 0.39; 'to:addr:python.org': 0.39; 'how': 0.39; 'back': 0.61; '2011': 0.62; 'mar': 0.64; 'details': 0.64; 'cause': 0.65; '30,': 0.80; '10:34': 0.84; 'received:129': 0.84; 'yesterday.': 0.84
MIME-Version 1.0
In-Reply-To <f87a430c-2385-4731-9dfb-ecdfb07af0e5@i35g2000prd.googlegroups.com>
References <f87a430c-2385-4731-9dfb-ecdfb07af0e5@i35g2000prd.googlegroups.com>
Date Wed, 30 Mar 2011 10:52:27 -0400
Subject Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file
From Benjamin Kaplan <benjamin.kaplan@case.edu>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Junkmail-Status score=10/49, host=mpv2.tis.cwru.edu
X-Junkmail-SD-Raw score=unknown, refid=str=0001.0A020205.4D9343AC.020B,ss=1,fgs=0, ip=74.125.82.44, so=2010-02-10 23:06:36, dmn=2009-09-10 00:05:08, mode=single engine
X-Junkmail-IWF false
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14.1301496819.2990.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 82.94.164.166
X-Trace 1301496819 news.xs4all.nl 81481 [::ffff:82.94.164.166]:53904
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2234

Show key headers only | View raw


On Wed, Mar 30, 2011 at 10:34 AM, Gnarlodious <gnarlodious@gmail.com> wrote:
> RSS script runs fine on my dev machine but errors on the server
> machine. Script was last run 3 days ago with no problem. Possible
> clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
> running Python 3.1.3. I have not updated anything that should suddenly
> cause this error starting yesterday.
>
> The error originates at 'ยท' which string contains a &middot;
> 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
>
> Any help how to fix this and why it suddenly started erroring 2 days
> ago...
>
> -- Gnarlie

You don't have a &middot character. Your computer doesn't understand
"characters". You have the byte sequence \xc2\xb7. When you have a
Unicode string (the default in Python 3), Python needs some way of
converting the byte sequence to a character sequence. The way it does
that is through the encoding. But you don't have an encoding
specified, so rather than guess, Python is falling back on the lowest
common denominator: ASCII, which doesn't understand the byte \xc2-
hence the error.

To fix this, just put the line
# coding=utf-8
at the very top of the code file.

> --
> http://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Gnarlodious <gnarlodious@gmail.com> - 2011-03-30 07:34 -0700
  Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-03-30 10:52 -0400
    Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Peter Otten <__peter__@web.de> - 2011-03-30 17:30 +0200
  Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Peter Otten <__peter__@web.de> - 2011-03-30 17:28 +0200
    Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Gnarlodious <gnarlodious@gmail.com> - 2011-03-30 16:58 -0700
      Re: Sudden error: SyntaxError: Non-ASCII character '\xc2' in file Terry Reedy <tjreedy@udel.edu> - 2011-03-30 22:36 -0400

csiph-web