Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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; 'subject:text': 0.05; 'affected': 0.07; 'utf-8': 0.07; 'versions.': 0.07; 'badly': 0.09; 'bug.': 0.09; 'decodes': 0.09; 'terms,': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'bytes': 0.24; 'cc:2**0': 0.24; 'supported': 0.26; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'am,': 0.29; 'said,': 0.30; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'skip:b 30': 0.33; 'objects': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'should': 0.36; 'being': 0.38; 'does': 0.39; 'provide': 0.64; 'mar': 0.68; 'invalid': 0.68; '2015': 0.84; 'to:none': 0.92; 'suffer': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=AhOfD9mu4mHtd1sR5nephW1DHW+kFEYO0Y7iKK7mT+U=; b=efLfrcE0K5VyjApQW4DkEPOiQlNROA2W7VzyEzR0SWEGM2DEK/p1nvGnrdGVgXy9Tg kDAS01kQoxXlRF8MNIypvreC8k9gFbCr2mKf93kGmuCFAqrevoIVQcbXJTAci8ATeQaS TDs6fD+ZP0Pk8+5GOcRS+xQeErXHd6GMruY5e/CDx0SFLnnV5unLmFiwOIj5yYEFdliB HI82LVx6M+Hbdp7gFdoZUbB5ZOIbGHcTD1RnWJNtK8ObgUR2Ql+9R5zYcbJDRbEzcfkd Pkvip5DN/Gq+muHY4zqlo25n5O3ciqURiZ7oYZ/YRnxXUFZObBBjuvGKhPsfL9qpSXN8 5Pvw== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr36184139ioe.43.1425745077426; Sat, 07 Mar 2015 08:17:57 -0800 (PST) In-Reply-To: <87twxw4xlz.fsf@elektro.pacujo.net> References: <54ECB134.5090304@davea.name> <201502241945.t1OJjshO013092@fido.openend.se> <201502241957.t1OJvrJS015604@fido.openend.se> <9169f3b1-2ac7-42a3-8033-584f84b88a1f@googlegroups.com> <7a75a23c-4678-4d7a-a2ec-9e8fff4c07f8@googlegroups.com> <132d5ce6-f672-4eec-99f9-1cc9e88b94f3@googlegroups.com> <619e4cb5-1c4c-449b-a5d7-951101b32b45@googlegroups.com> <54f862ca$0$13014$c3e8da3$5496439d@news.astraweb.com> <54fadc70$0$13004$c3e8da3$5496439d@news.astraweb.com> <87twxxxbvd.fsf@elektro.pacujo.net> <54fb1bf4$0$12993$c3e8da3$5496439d@news.astraweb.com> <87twxw4xlz.fsf@elektro.pacujo.net> Date: Sun, 8 Mar 2015 03:17:57 +1100 Subject: Re: Newbie question about text encoding From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425745085 news.xs4all.nl 2954 [2001:888:2000:d::a6]:45697 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87099 On Sun, Mar 8, 2015 at 2:48 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Marko Rauhamaa wrote: >> >>> That said, UTF-8 does suffer badly from its not being >>> a bijective mapping. >> >> Can you explain? > > In Python terms, there are bytes objects b that don't satisfy: > > b.decode('utf-8').encode('utf-8') == b Please provide an example; that sounds like a bug. If there is any invalid UTF-8 stream which decodes without an error, it is actually a security bug, and should be fixed pronto in all affected and supported versions. ChrisA