Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'that?': 0.05; "subject:' ": 0.07; 'utf-8': 0.07; 'string': 0.09; 'assuming': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:position': 0.09; 'python': 0.11; 'codec': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:start': 0.16; 'thread,': 0.16; 'unicode,': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'error': 0.23; 'byte': 0.24; 'specify': 0.24; '(or': 0.24; 'environment': 0.24; 'question': 0.24; 'source': 0.25; 'script': 0.25; 'skip:" 40': 0.26; 'least': 0.26; 'certain': 0.27; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'host': 0.29; 'am,': 0.29; 'character': 0.29; "i'm": 0.30; 'gives': 0.31; 'file': 0.32; '(most': 0.33; 'candidate': 0.34; "can't": 0.35; 'display': 0.35; 'version': 0.36; 'shows': 0.36; 'should': 0.36; 'changing': 0.37; 'error.': 0.37; 'starting': 0.37; 'skip:o 20': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'track': 0.38; 'recent': 0.39; 'does': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'address.': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'most': 0.60; 'new': 0.61; 'first': 0.61; 'invalid': 0.68; 'legal': 0.71; 'jul': 0.74; '2.7.': 0.84; 'premature': 0.84; 'was:': 0.91; 'from.': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Date: Thu, 04 Jul 2013 05:59:22 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 174.32.174.34 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372931978 news.xs4all.nl 15913 [2001:888:2000:d::a6]:58572 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49831 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 > [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. -- DaveA