Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2232 > unrolled thread
| Started by | Gnarlodious <gnarlodious@gmail.com> |
|---|---|
| First post | 2011-03-30 07:34 -0700 |
| Last post | 2011-03-30 22:36 -0400 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.python
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
| From | Gnarlodious <gnarlodious@gmail.com> |
|---|---|
| Date | 2011-03-30 07:34 -0700 |
| Subject | Sudden error: SyntaxError: Non-ASCII character '\xc2' in file |
| Message-ID | <f87a430c-2385-4731-9dfb-ecdfb07af0e5@i35g2000prd.googlegroups.com> |
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 · 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
[toc] | [next] | [standalone]
| From | Benjamin Kaplan <benjamin.kaplan@case.edu> |
|---|---|
| Date | 2011-03-30 10:52 -0400 |
| Message-ID | <mailman.14.1301496819.2990.python-list@python.org> |
| In reply to | #2232 |
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 · > 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 · 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 >
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-03-30 17:30 +0200 |
| Message-ID | <imvibb$d45$01$2@news.t-online.com> |
| In reply to | #2234 |
Benjamin Kaplan wrote: > 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 · >> 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 · 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. All good advice except that Python 3 defaults to UTF-8 not ASCII as its source encoding.
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-03-30 17:28 +0200 |
| Message-ID | <imvi69$d45$01$1@news.t-online.com> |
| In reply to | #2232 |
Gnarlodious 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 · > 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... You are trying to run your 3.x code with Python 2.x...
[toc] | [prev] | [next] | [standalone]
| From | Gnarlodious <gnarlodious@gmail.com> |
|---|---|
| Date | 2011-03-30 16:58 -0700 |
| Message-ID | <2851a17f-cac9-43a5-bbf4-dcb2e22520ad@o15g2000prn.googlegroups.com> |
| In reply to | #2235 |
On Mar 30, 9:28 am, Peter Otten wrote: > You are trying to run your 3.x code with Python 2.x... You're right. Exactly why this started happening I don't know. Thanks. -- Gnarlie
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2011-03-30 22:36 -0400 |
| Message-ID | <mailman.24.1301539016.2990.python-list@python.org> |
| In reply to | #2254 |
On 3/30/2011 7:58 PM, Gnarlodious wrote: > On Mar 30, 9:28 am, Peter Otten wrote: > >> You are trying to run your 3.x code with Python 2.x... > > You're right. Exactly why this started happening I don't know. I believe recent Mac OSX comes with some 2.x installed as the default Python. -- Terry Jan Reedy
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web