Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '(python': 0.07; "subject:' ": 0.07; '[0]': 0.09; 'subject:position': 0.09; 'url:unicode': 0.09; 'will,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'codec': 0.16; 'isnt': 0.16; 'subject: \n ': 0.16; 'subject:start': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'script.': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'host': 0.29; 'chris': 0.29; 'am,': 0.29; 'nature': 0.30; 'code': 0.31; 'sep': 0.31; 'there.': 0.32; 'another': 0.32; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; "he's": 0.36; 'pm,': 0.38; 'subject:can': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 're:': 0.63; 'today': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'determine': 0.67; 'invalid': 0.68; '8bit%:92': 0.71; 'pain': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=uyj07HKfqIUP+UGVeC0ozROSfrcJa/+lPgLjTFJNGNc=; b=KWAhQ16X4QT49xkB0kxV9LHjj7R8j9pryP6a3zHff/1NjU6bDivnSVyGTSDV0JO6e9 RPRNwuFz2KJkgSDocisv5lp/z3INk0rFQkRIRUPI3Wl59xKMwj4PAwgdnomaXojVy4hT PWz6NbxCUv15RuSULqcU2TmXbUYNC3hICyaWjUy5RKxwBEZHyJWodZHUHU+4yW5zaKn2 ybbWcLTipDXdCESIQ0jVutEiizsYjEs3rTi5UNx5OIVAxxbYLXXkFPv9U9aYTOs3zg05 oCOMzGMYCXpHvDDf9XQX80LS4EOpvD5GjfBHSw9NeGWjfzazaj4rOyCDpk2ybZGN36+/ PeBA== X-Received: by 10.49.63.39 with SMTP id d7mr21353599qes.78.1380452008127; Sun, 29 Sep 2013 03:53:28 -0700 (PDT) Sender: Ned Batchelder Date: Sun, 29 Sep 2013 06:53:27 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: =?UTF-8?B?zp3Or866zr/Pgg==?= Subject: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: python-list@python.org 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380452016 news.xs4all.nl 15864 [2001:888:2000:d::a6]:33681 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55002 On 9/29/13 4:04 AM, Νίκος wrote: > Στις 29/9/2013 11:00 πμ, ο/η Chris Angelico έγραψε: >> On Sun, Sep 29, 2013 at 5:53 PM, Νίκος wrote: >>> Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in >>> position 0: >>> invalid start byte >> >> Something's trying to decode a stream of bytes as UTF-8, and it's not >> UTF-8. Work out what in your code is bytes and what is strings, and do >> your own conversions. >> >> http://www.joelonsoftware.com/articles/Unicode.html >> >> READ IT. Do not write another line of code until you actually >> understand what he's saying there. >> >> ChrisA >> > okey i will, but isnt this just weird: > > How come all these daysthe followinf line work as expected: > > host = socket.gethostbyaddr( ipval ) [0] > > and only just today just happened to output: > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: > invalid start byte erros? > > Nothign got added in my script. This is the only line that tried to > determine the host. This is the nature of Unicode pain in Python 2 (Python 3 has a different kind!). This may help you understand what's going on: http://nedbatchelder.com/text/unipain.html --Ned.