UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

Νίκος nikos at superhost.gr
Thu Jul 4 12:03:55 CEST 2013


Στις 4/7/2013 12:59 μμ, ο/η Dave Angel έγραψε:
> On 07/04/2013 04:37 AM, Νίκος wrote:
>> I just started to have this error without changing nothing
>>
>> in my index.html(template) and metrites.py(which ipen the template)
>>
>> [Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
>> exception was: [Thu Jul 04 11:35:14 2013] [error] [client
>> 108.162.229.97] Traceback (most recent call last): [Thu Jul 04
>> 11:35:14 2013] [error] [client 108.162.229.97]   File
>> "/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
>> [Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97]     host =
>>  socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
>> 'UnResolved' [Thu Jul 04 11:35:14 2013] [error] [client
>> 108.162.229.97] UnicodeDecodeError: 'utf-8' codec can't decode byte
>> 0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013]
>> [error] [client 108.162.229.97] Premature end of script headers:
>> metrites.py
>>
>>
>> Why cant it decode the starting byte? what starting byte is that?
>
> The error message means that somebody is trying to decode a byte string
> into Unicode, and using the utf-8 codec for it.  Only certain sequences
> are legal in utf-8, and the first byte of a character may not be 0xb6.
> So it gives an error.  The question is where does this string come from.
>
>
> Well, the message shows the source line from metrites.py:
>
> host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or 'UnResolved'
>
> So the most likely candidate is the string in the environment named
> "REMOTE_ADDR"  Can you display that string?  it should look like
>
> "11.24.32.4"
>
> or some other valid IP address.
>
>
> I'm assuming Python 2.7.  You should specify the python version when
> starting a new thread, as we (or at least I) cannot keep track of what
> version everyone's running.

Ima using Python v3.3.2 Dave

The host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or 
'UnResolved' should not have give an error since i explicityl tell it 
that if it cannot resolve dns the ip to hostname to set it as "unresolved"

The error appear ONLY when i CloudFlare superhost.gr

If i pause tthe domain form CloudFlare then my website loads properly.


-- 
What is now proved was at first only imagined!



More information about the Python-list mailing list