Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(python': 0.07; '*not*': 0.07; 'error:': 0.07; 'float': 0.07; "subject:' ": 0.07; '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; 'jan': 0.12; 'random': 0.14; 'losing': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'subject:start': 0.16; 'unicode.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'nature': 0.30; '"",': 0.31; 'minor': 0.31; 'file': 0.32; '(most': 0.33; '"the': 0.34; 'sense': 0.34; "can't": 0.35; 'convert': 0.35; 'there': 0.35; 'really': 0.36; 'combination': 0.36; 'shows': 0.36; 'too': 0.37; 'problems': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'conversion': 0.61; 'received:173': 0.61; 'different': 0.65; 'skip:1 20': 0.65; 'batchelder': 0.84; 'correction,': 0.84; 'pain': 0.84; 'received:fios.verizon.net': 0.84; 'strengthened': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Date: Sun, 29 Sep 2013 13:30:48 -0400 References: <524806A7.1050000@nedbatchelder.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <524806A7.1050000@nedbatchelder.com> 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380475864 news.xs4all.nl 15953 [2001:888:2000:d::a6]:60874 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55029 On 9/29/2013 6:53 AM, Ned Batchelder wrote: > 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 This is really excellent and I bookmarked it. There is one minor error: "the conversion from int to float can't fail," >>> float(10**1000) Traceback (most recent call last): File "", line 1, in float(10**1000) OverflowError: long int too large to convert to float Even when it succeeds, it can fail in the sense of losing information. >>> int(float(12345678901234567890)) 12345678901234567168 >>> float(int(1.55)) 1.0 This is somewhat analogous to a combination of errors='ignore' and errors='replace' (with random garbage). I think the presentation would be strengthened with the correction, as it shows that the problems of conversion are *not* unique to bytes and unicode. -- Terry Jan Reedy